文件读取的问题 在线等

来源:百度知道 编辑:UC知道 时间:2024/06/08 03:47:46
读取一个存储信息的文件(txt) 用什么样的方法能比较快速的把文件信息放到相关的结构体数组里面
struct student{
char name;
char sex;
int age;
....
} a[50] 这样一个数组
高手随便给个程序看看 在线等
用C编的程序

#include<iostream>
#include<conio.h>
#include<fstream>
#include<windows.h>
#include<io.h>
#include<iomanip>
#define OK 1
#define ERROR 0
using namespace std;

typedef int Status; /*返回值的类型*/

static int STU_COUNT=0;

typedef struct student
{
char num[20];
char name[20];
char sex[4];
char speciality[20];
student *next;

}node;

typedef struct LIST
{
node *head,*tail;

}link;

Status AvgScore(link *s); /*声明一下求平均值的函数*/

node *MakeNode(char num[],char name[],char sex[],char speciality[]) /*生成存放学生信息的节点*/
{
node *p=(node *)malloc(sizeof(node));
strcpy(p->num,num); /*存放学号*/
strcpy(p->name,name);
strcpy(p->sex,sex);
strcpy(p->speciality,speciality);

p->next=NULL; /*刚生成的节点下一个为空*/
return p;
}
Statu