C语言read函数漏洞 c语言readdir函数( 三 )


p-sex=male;
}
printf("输入成绩,语数外的顺序");
scanf("%d%d%d",(p-score[0]),(p-score[1]),(p-score[2]));
p0-next=p;
p0=p;
i++;
}
p0-next=NULL;
return
head;
}
void writefile0(struct student*head) //已知链表头head,将之写入文件中
{
struct student*p1;
FILE *f0;
char string[40];
printf("请输入文件路径或者文件名字!(扩展名)");
scanf("%s",string);
f0=fopen(string,"w");
//新建一个文件
p1=head;
while(p1!=NULL)
{
fprintf(f0,"%5s ",p1-number);
fprintf(f0,"%5s ",p1-name);
fprintf(f0,"%5d ",p1-sex);
fprintf(f0,"%5d ",p1-score[0]);
fprintf(f0,"%5d ",p1-score[1]);
fprintf(f0,"%5d\n",p1-score[2]);
p1=p1-next;
}
printf("所有学生的信息已写入文件%s中\n",string);
fclose(f0);
}
struct student* readfile0() //读取原始文件(所有学生的信息)
{
FILE *f0;
struct student *head=NULL, *tail,*m;
char string[40];
student temp;
printf("请输入总信息的文件名:");
scanf("%s",string);
while((f0=fopen(string,"r"))==NULL)
{
printf("不能打开,重新输入\n");
scanf("%s",string);
}
while(!feof(f0))
{
fread(temp,sizeof(struct student),1,f0);
m=(struct student*)malloc(sizeof(struct student));
*m = temp;
if ( head==NULL )
head=m;
else
tail-next=m;
tail=m;
}
tail-next=NULL;
printf("该文件已打开!\n");
fclose(f0);
return
head;
}
void Free(student * head)
{
student *p = head;
while(p != NULL)
{
p = head-next;
free(head);
head = p;
}
}
void main()
{
struct student* base0;
struct student* base1;
base0=inputcard();
writefile0(base0);
base1=readfile0();
Free(base0);
Free(base1);
}
关于C语言read函数漏洞和c语言readdir函数的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读