C语言关于链表文件的东西

来源:百度知道 编辑:UC知道 时间:2024/05/17 09:36:12
#include "stdio.h"
#include "malloc.h"
#include "conio.h"
#include "stdlib.h"
#define LEN sizeof(struct user)

void F_write(struct user *p);
void print(struct user *head);
struct user F_read();

struct user
{
int num;
int shouzhi;
char menlei[10];
char shijian[15];
struct user *next;
};

struct user *creat(void)
{
struct user *head;
struct user *p1,*p2;
int n=0;
p1=p2=(struct user *)malloc(sizeof(struct user));
scanf("%d,%d,%s,%s",&p1->num,&p1->shouzhi,&p1->menlei,&p1->shijian);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct user *)malloc(sizeof(struct user));
scanf("%d,%d,%s,%s",&p1->num,&p1->shouzhi,&p1->menlei,&p1->shijian);
}
p2->next=NU

问题不少啊。。
改完的:
#include "stdio.h"
#include "malloc.h"
#include "conio.h"
#include "stdlib.h"
#define LEN sizeof(struct user)

void F_write(struct user *p);
void print(struct user *head);
struct user * F_read();

struct user
{
int num;
int shouzhi;
char menlei[10];
char shijian[15];
struct user *next;
};

struct user *creat(void)
{
struct user *head;
struct user *p1,*p2;
int n=0;
p1=p2=(struct user *)malloc(sizeof(struct user));
scanf("%d,%d,%s %s",&p1->num,&p1->shouzhi,&p1->menlei,&p1->shijian);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)head=p1;
else
{ p2->next=p1;
p2=p1;
}
p1=(struct user *)malloc(sizeof(struct user));
scanf("%d,%d,%s %s",&p1->num,&p1->shouzhi,&p1->menlei,&p1-&