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 << "行号"<<lenth<< endl;
//printf("%p,%d",buffer+1,sizeof(buffer));
const char *d = ", ";
char *p;
int n = 0;
int date;
float v;
//printf("\n%s,n=%d,lenth=%d\n",buffer,n,lenth);
p = strtok(buffer,d);
while(p)
{
//printf("\n%s,n=%d,lenth
c++ 结构体数组作为返回值
最新推荐文章于 2023-12-12 22:29:41 发布