链表读文件
请问大家,在txt文件中,有一表格形式的数据,怎样将他们读入结构体链表中,比如说结构体类型:
typedef struct student
{
char num;
char name;
int name;
int tax;
int english;
int math;
int sorce;
struct student *next;
}JD;
文件:student.txt
10000 zhanghua 85 65
10001 yangliwei 69 85
10002 lipeng 69 78
请问在这当中,怎么将文本文件中的学号读入链表中的num,姓名读入name,英语读入english,数学读入math;
typedef struct student
{
char num;
char name;
int name;
int tax;
int english;
int math;
int sorce;
struct student *next;
}JD;
文件:student.txt
10000 zhanghua 85 65
10001 yangliwei 69 85
10002 lipeng 69 78
请问在这当中,怎么将文本文件中的学号读入链表中的num,姓名读入name,英语读入english,数学读入math;
作者: chedesheng 发布时间: 2011-06-16
一行行读,一个个分析,这要看你的规则是什么了
作者: bdmh 发布时间: 2011-06-16
fgets
或者fscanf读
然后给对应的节点赋值
字符串的赋值用strcpy
或者fscanf读
然后给对应的节点赋值
字符串的赋值用strcpy
作者: q191201771 发布时间: 2011-06-16
可以的的,你们可以给出一两名例子吗,也就是程序代码
作者: chedesheng 发布时间: 2011-06-16