这个c语言为什么运行不出来求解,它提示这个错误 fi_info*h=NULL,*p1=NULL,*P2=NULL; 但我不知道这个哪里
这是程序#include<stdio.h>#include<stdlib.h>#include<conio.h>#include<string.h>#include<co...
这是程序
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<conio.h>
#define MAXNAME 11
#define MAXDETAIL 21
#define MENU_COUNT 9
typedef enum _fi_type
{
income=1,
payout =-1
}fi_type;
typedef struct tel
{
int year;
int month;
fi_type type;
char name[MAXNAME];
float money;
char detail[MAXDETAIL];
tel*next;
}fi_info;
fi_info*initialize()
{
FILE *fp
fi_info*h=NULL,*p1=NULL,*P2=NULL;
if((fp=fopen(data.txt,"w"))==NULL)
{
printf("\t无法打开文件\n");
system("pause");
fp=fopen(data.txt,"w+")
}
while(!feof(fp) )
{ p1=(fi_info*)malloc (sizeof(fi_info));
fscanf(fp,"%d%d%f%s%s\n",&p1->year,&p1->month,&p1->money,p1->name,p1->detail);
if(h==NULL)
{
h=p1;
p1->next=NULL;
p2=p1;
}
else
{
p2->next=p1;
p1->next=NULL;
p2=p1;
}
}
fclose(fp);
return h;
}
int main()
{
fi_info*head;
head=initialize();
} 展开
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<conio.h>
#define MAXNAME 11
#define MAXDETAIL 21
#define MENU_COUNT 9
typedef enum _fi_type
{
income=1,
payout =-1
}fi_type;
typedef struct tel
{
int year;
int month;
fi_type type;
char name[MAXNAME];
float money;
char detail[MAXDETAIL];
tel*next;
}fi_info;
fi_info*initialize()
{
FILE *fp
fi_info*h=NULL,*p1=NULL,*P2=NULL;
if((fp=fopen(data.txt,"w"))==NULL)
{
printf("\t无法打开文件\n");
system("pause");
fp=fopen(data.txt,"w+")
}
while(!feof(fp) )
{ p1=(fi_info*)malloc (sizeof(fi_info));
fscanf(fp,"%d%d%f%s%s\n",&p1->year,&p1->month,&p1->money,p1->name,p1->detail);
if(h==NULL)
{
h=p1;
p1->next=NULL;
p2=p1;
}
else
{
p2->next=p1;
p1->next=NULL;
p2=p1;
}
}
fclose(fp);
return h;
}
int main()
{
fi_info*head;
head=initialize();
} 展开
2个回答
推荐于2016-01-16
展开全部
提示这个错误的原因是这一行的上一行末尾少了必要的分号。程序还有其它的语法错误,修改如下:
/*
* File: main.c
* Author: administrator
*
* Created on 2011年4月21日, 下午3:39
*/
#include<stdio.h>
#include<stdlib.h>
//#include<conio.h>
#include<string.h>
//#include<conio.h>
#define MAXNAME 11
#define MAXDETAIL 21
#define MENU_COUNT 9
typedef enum _fi_type
{
income=1,
payout =-1
}fi_type;
typedef struct tel
{
int year;
int month;
fi_type type;
char name[MAXNAME];
float money;
char detail[MAXDETAIL];
struct tel *next;
}fi_info;
fi_info*initialize()
{
FILE *fp;//**************注意这里
fi_info*h=NULL,*p1=NULL,*p2=NULL;//**************注意这里
if((fp=fopen("data.txt","w"))==NULL)//**************注意这里
{
printf("\t无法打开文件\n");
system("pause");
fp=fopen("data.txt","w+");//**************注意这里
}
while(!feof(fp) )
{ p1=(fi_info*)malloc (sizeof(fi_info));
fscanf(fp,"%d%d%f%s%s\n",&p1->year,&p1->month,&p1->money,p1->name,p1->detail);
if(h==NULL)
{
h=p1;
p1->next=NULL;
p2=p1;
}
else
{
p2->next=p1;
p1->next=NULL;
p2=p1;
}
}
fclose(fp);
return h;
}
int main()
{
fi_info*head;
head=initialize();
}
/*
* File: main.c
* Author: administrator
*
* Created on 2011年4月21日, 下午3:39
*/
#include<stdio.h>
#include<stdlib.h>
//#include<conio.h>
#include<string.h>
//#include<conio.h>
#define MAXNAME 11
#define MAXDETAIL 21
#define MENU_COUNT 9
typedef enum _fi_type
{
income=1,
payout =-1
}fi_type;
typedef struct tel
{
int year;
int month;
fi_type type;
char name[MAXNAME];
float money;
char detail[MAXDETAIL];
struct tel *next;
}fi_info;
fi_info*initialize()
{
FILE *fp;//**************注意这里
fi_info*h=NULL,*p1=NULL,*p2=NULL;//**************注意这里
if((fp=fopen("data.txt","w"))==NULL)//**************注意这里
{
printf("\t无法打开文件\n");
system("pause");
fp=fopen("data.txt","w+");//**************注意这里
}
while(!feof(fp) )
{ p1=(fi_info*)malloc (sizeof(fi_info));
fscanf(fp,"%d%d%f%s%s\n",&p1->year,&p1->month,&p1->money,p1->name,p1->detail);
if(h==NULL)
{
h=p1;
p1->next=NULL;
p2=p1;
}
else
{
p2->next=p1;
p1->next=NULL;
p2=p1;
}
}
fclose(fp);
return h;
}
int main()
{
fi_info*head;
head=initialize();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询