c语言 链表的创建 帮忙看看哪错了谢谢~~

来源:百度知道 编辑:UC知道 时间:2024/07/02 00:57:13
typedef struct information
{ char ID[10];
char name[20];
int number;
char address[256];
float rsum;/*余额*/
float expenditure;/*支出金额*/
float savings;/*存入金额*/
char newifo[100];
struct information *next;
}ifo;

ifo *input()
{int n,i;
ifo *p,*h,*s;
h=(ifo *)malloc(sizeof(ifo));
h->next=NULL;
p=h;
s=(ifo *) malloc(sizeof(ifo));
puts("input information:");
puts("example:0816000406 zhangqianwen 64589452 shanghaibaoshan 3000.00 1239.00\n ID name number address expenditure savings");
printf("输入用户的数目n:");
scanf("%d",&n);
printf("请根据样例输入n组数据:\n");
for(i=0;i<n;i++)
{
scanf("%s%s%d%s%f%f",s->ID,s->name,&s->number,s->address,&s->expenditure,&s->savings);
p->next=s;
p=s;
}
s->next=NULL;
return(h)

#include <stdio.h>
#include <conio.h>
#include <malloc.h>

typedef struct information
{
char ID[11];
char name[20];
int number;
char address[256];
float rsum;/*余额*/
float expenditure;/*支出金额*/
float savings;/*存入金额*/
char newifo[100];
struct information *next;
}ifo;

ifo *input()
{
int n,i;
ifo *p,*h,*s;
h=(ifo *)malloc(sizeof(ifo));
h->next=NULL;
p=h;

puts("input information:");
puts("example:0816000406 zhangqianwen 64589452 shanghaibaoshan 3000.00 1239.00\n ID name number address expenditure savings");
printf("输入用户的数目n:");
scanf("%d",&n);
printf("请根据样例输入n组数据:\n");
for(i=0;i<n;i++)
{
s=(ifo *) malloc(sizeof(ifo));
scanf("%s %s %d %s %f %f",s->ID,s->name,&s->n