程序很多。。我只贴出来有问题的部分。。。
文件名:mrk.dat 下面是数据。。。
ID, name, mark1, mark2, mark3, finalmark, grade(注解)
--------------------------------------------------------------
0602R00001,Alex Zhu,12.5,20.5,35,68,CR
0602R12345,Bobby Brain,14.5,24.5,59.5,98.5,HD
0602R98765,Charles Laz,7,0,0,0,F
0602R87654,Daniel Dun,8
0602R22222,Eyvonne Young,10
0602R33333,Fiona Ou,11.5
0602R99993,Lewis Chen,8.5,18,49,75.5,DI
code:
#define ID_MAX 10
#define NAME_MAX 25
#define MARK_MAX 4
#define GRADE_MAX 2
#define MAX 100
typedef struct studentNode
{
char id[ID_MAX + 1];
char name[NAME_MAX + 1];
float mark[MARK_MAX]; /*这里只给了一个array。。。*/
char grade[GRADE_MAX + 1];
struct studentNode* nextStudent;
} StudentNode;
typedef struct studentList
{
StudentNode* head;
} ClassList;
void loadStudent(ClassList* student, char* markFile)
{
FILE* fp;
char *tokens[7];
char *tokens2;
int i;
if((fp = fopen(markFile,"r")) == NULL)
{
fprintf(stderr, "\n***>>>Error to Open in file %s\n", markFile);
exit(1);
}
else
while(fgets(markFile,MAX, fp) != NULL)
{
i = 0;
tokens2 = strtok(markFile,",");
while(tokens2 != NULL)
{
tokens[i] = tokens2;
tokens2 = strtok(NULL,",");
i++;
}
/*这里有问题。。。。其实不知道要怎么写。。。。。..
我想先测试一下可不可以读取到数据。。。所以用printf。。。*/
printf(?????);
}
fclose(fp);
}
拜托各位看一下~~先谢了~~