中易网

fatal error C1004: unexpected end of file found

答案:3  悬赏:50  
解决时间 2021-02-11 14:44
fatal error C1004: unexpected end of file found
最佳答案
问题太多了,,,
变量名重名且还用到关键字。

修改结果如下:

#include "conio.h"
#include
#include "dos.h"

struct addr
{
char postnum[10];
char saddr[80];
};

struct birth
{
int year;
int month;
int day;
};

struct mefriend
{
int number;
char name[20];
char sex[6];
struct birth sbirth;
struct addr saddr;
char telephone[13];

} mefriends[50];

FILE * fp;
int i;
void dataload()
{
int j;
long k;
fp=fopen("mefriend.txt","r+t");
if(fp!=NULL)
{
for(i=1;i<50;i++)
{
if ((j=fgetc(fp))==EOF)
return;
k=i-1;

fseek(fp,k* sizeof(mefriend),10);
fread(&mefriends[i],sizeof(mefriend),1,fp);
}
}
else
{
fp=fopen("friend.txt","w");
i=1;
}
}

void datashow(int j)
{
printf("\n\n\t序号:%3d\n",mefriends[j].number);
printf("\n\n\t姓名:%-20s\n\n\t性别:%s\n",mefriends[j].name,mefriends[j].sex);
printf("\n\t生日(y/m/d):%4d%2d%2d\n",mefriends[j].sbirth.year,mefriends[j].sbirth.month,mefriends[j].sbirth.day);
printf("\n\t邮编:%-10s\n",mefriends[j].saddr.postnum);
printf("\n\t电话:%-13s\n",mefriends[j].telephone);
}

void datainput(int j)
{
mefriends[j].number=j;
printf("\n\n\n\t序号%d",j);
printf("\n\n\t姓名:");
scanf("%s",mefriends[j].name);
printf("\n\t性别(m/f):");
scanf("%s",mefriends[j].sex);
printf("\n\t生日");
printf("\n\t\t年");
scanf("%d",&mefriends[j].sbirth.year);
printf("\n\t\t月");
scanf("%d",&mefriends[j].sbirth.month);
printf("\n\t\t日");
scanf("%d",&mefriends[j].sbirth.day);
printf("\n\t\t邮编");
scanf("%s",&mefriends[j].saddr.postnum);
printf("\n\t\t地址");
scanf("%s",&mefriends[j].saddr.saddr);
printf("\n\t\t电话");
scanf("%s",&mefriends[j].telephone);
}
void datasave()
{
int j;
fp=fopen("friend.txt","w");
for(j=1;j<=i;j++)
{
fwrite(&mefriends[j],sizeof(struct mefriend),1,fp);
}
}

只是把错误修改了,功能上只有你自己调试了。
全部回答
#include "stdafx.h" 看看{}()[]是不是匹配
input函数内少了一个大括号,修改如下,看看哈:) #include #include #include #include using namespace std; string cell,attribute,value; multimap > temptable1; multimap >::const_iterator iter; pair something1,something2; void input() //目的,可以向mulitmap容器中,添加数据,一次想添加多少,添加多少,包括键值和second { cout<<"please input attribute,cell and value "<>attribute>>cell>>value&& attribute !="quit") {something1 = make_pair(cell,value); temptable1.insert( make_pair(attribute,something1) ); } \\+++++++++++++++++++++} } void main() { input(); for(iter=temptable1.begin();iter != temptable1.end() ;iter++) { something2 = iter->second; cout<
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯