VC如何读取.csv文件内容
//自定义结构体来保存数据 typedef struct tagMYDATA { char Designator[20]; char Footprint[20]; float MidX; float MidY; float RefX; float RefY; float PadX; float PadY; char Layer[4]; float Rotation; char Comment[20]; }MYDATA; //自定义一个函数来解析数据行 void GetData(char *Str,MYDATA *md) { char buf[1024]={0}; int v[11]={0}; int i=0,j=1; char *p=Str; if(NULL==md) return; memset(md,0,sizeof(MYDATA)); if(NULL==Str) return; while(*p) { if(*p=='\"') { if((*(p+1)==',')&&(*(p+2)=='\"')) { buf[i]=0x20; p+=3; i++; v[j]=i; j++; } else p++; } else if(*p=='m') { if(*(p+1)!='m') { buf[i]=*p; p++; i++; } else p+=2; } else { buf[i]=*p; p++; i++; } } sscanf(buf+v[0], "%s",md->Designator); sscanf(buf+v[1], "%s",md->Footprint); sscanf(buf+v[2], "%f",&md->MidX); sscanf(buf+v[3], "%f",&md->MidY); sscanf(buf+v[4], "%f",&md->RefX); sscanf(buf+v[5], "%f",&md->RefY); sscanf(buf+v[6], "%f",&md->PadX); sscanf(buf+v[7], "%f",&md->PadY); sscanf(buf+v[8], "%s",md->Layer); sscanf(buf+v[9], "%f",&md->Rotation); sscanf(buf+v[10],"%s",&md->Comment); }