c++ 结构体数组作为返回值

struct sig
{
	int a;
	float b;
};

struct sigs
{
	struct sig *sigdata; //数组首地址
	int siglen;
};



struct sigs readfile(string path){
	char buffer[256];
	struct sigs mysigdata;
	ifstream infile(path.c_str());
	if(!infile.is_open()){
		//cout << "error" << endl;
	}else
	{
		int lenth = 0;
		//struct sigs mysigs;
		int filelen = getnum(path);
		cout << "行数" << filelen << endl;
		mysigdata.sigdata = (struct sig *)malloc(sizeof(struct sig)*filelen); //分配内存
		while(!infile.eof()){
			infile.getline(buffer,100);
			//cout << buffer << "行号"<

转载于:https://my.oschina.net/madeitcwang/blog/887071

你可能感兴趣的:(c/c++)