c语言程序编译显示找不到文件,求助!急!
voidmain(){inta,b;FILE*fp;MessagesList*phead2,*alist,*blist;b=0;alist=(MessagesList*)...
void main()
{
int a,b;
FILE *fp;
MessagesList *phead2,*alist,*blist;
b=0;
alist=(MessagesList *)malloc(sizeof(MessagesList));
fp=fopen("shuju.dat","r+");
if(fp==NULL)
printf("Cannot find file!\n");
else
{
fscanf(fp,"%d%d%s%s%s%d",alist->m,alist->id,alist->buy_time,alist->driver,alist->price);
fscanf(fp,"%d%s%s%s",alist->pWZList->code,alist->pWZList->time,alist->pWZList->place,alist->pWZList->YorN);
while(feof(fp)==0)
{
b++;
if(b==1)
phead2=alist;
else
{
blist=alist;
alist=(MessagesList *)malloc(sizeof(MessagesList));
fscanf(fp,"%d%d%s%s%s%d",alist->m,alist->id,alist->buy_time,alist->driver,alist->price);
fscanf(fp,"%d%s%s%s",alist->pWZList->code,alist->pWZList->time,alist->pWZList->place,alist->pWZList->YorN);
blist->mnext=alist;
}
}
alist->mnext=NULL;
fclose(fp);
alist=blist=phead2;
}
mainmenu();
scanf("%d",&a);
fun_choose(a,phead2);
}
图1是我创建数据文件的工程,图2是我要导入数据文件的工程, 图3是.exe文件运行时的界面 展开
{
int a,b;
FILE *fp;
MessagesList *phead2,*alist,*blist;
b=0;
alist=(MessagesList *)malloc(sizeof(MessagesList));
fp=fopen("shuju.dat","r+");
if(fp==NULL)
printf("Cannot find file!\n");
else
{
fscanf(fp,"%d%d%s%s%s%d",alist->m,alist->id,alist->buy_time,alist->driver,alist->price);
fscanf(fp,"%d%s%s%s",alist->pWZList->code,alist->pWZList->time,alist->pWZList->place,alist->pWZList->YorN);
while(feof(fp)==0)
{
b++;
if(b==1)
phead2=alist;
else
{
blist=alist;
alist=(MessagesList *)malloc(sizeof(MessagesList));
fscanf(fp,"%d%d%s%s%s%d",alist->m,alist->id,alist->buy_time,alist->driver,alist->price);
fscanf(fp,"%d%s%s%s",alist->pWZList->code,alist->pWZList->time,alist->pWZList->place,alist->pWZList->YorN);
blist->mnext=alist;
}
}
alist->mnext=NULL;
fclose(fp);
alist=blist=phead2;
}
mainmenu();
scanf("%d",&a);
fun_choose(a,phead2);
}
图1是我创建数据文件的工程,图2是我要导入数据文件的工程, 图3是.exe文件运行时的界面 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询