我有一个csv文件里面内容: 1,20080101,asd,b,30.3,16.7,42.8,81.1,90.2 1,20080102,asd,b,51.6,92.8,23.1,40.6,21.6 1,20080103,asd,b,94,16.5,56.1,63.6,69 1,20080104,asd,b,73,63.9,65.1,44.9,41.7 代码: #include<stdio.h> struct student_type { int no; int id; char name[20]; char sex; float shuxue; float yuwen; float wuli; float huaxue; float yingyu; } stud[16],*st; struct sum_type { float shuxue; float yuwen; float wuli; float huaxue; float yingyu; float pingjun; }; main() { FILE *fp; /*定义一个文件指针*/ FILE *cp; /*定义一个文件指针*/ struct sum_type qq; st=stud; int i; float sx=0,yw=0,wl=0,hx=0,yy=0; fp=fopen("分数表.csv", "rb"); /*打开文件只读*/ for(i=0;i<16;i++,st++) { fscanf(fp,"%d,%d,%s,%c,%f,%f,%f,%f,%f\n",&st->no,&st->id,&st->name,&st->sex,&st->shuxue,&st->yuwen,&st->wuli,&st->huaxue,&st->yingyu); printf("sx=%s\n",st->name); sx+=st->shuxue; yw+=st->yuwen; wl+=st->wuli; hx+=st->huaxue; yy+=st->yingyu; } qq.shuxue=sx/16; qq.yuwen=yw/16; qq.wuli=wl/16; qq.huaxue=hx/16; qq.yingyu=yy/16; qq.pingjun=(qq.shuxue+qq.yuwen+qq.wuli+qq.huaxue+qq.yingyu)/5; cp=fopen("test.csv", "w"); /*建立一个文字文件只写*/ fwrite(&qq,sizeof(qq),1,cp); fclose(cp); /*关闭打开的文件*/ fclose(fp); /*关闭打开的文件*/ return 0; } 结果打印出来的name字段=asd,b,30.3,16.7,42.8,81.1,90.2 请教C高手,是什么问题,是读文件出错了吗?