编译错误提示

lfangqing2003 2005-04-17 07:24:06
小弟,在用VC++编译程序时,经常会碰到这个错误 “: fatal error C1004: unexpected end of file found”,不知何故?请各位指教一下!谢了
...全文
164 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
lfangqing2003 2005-04-18
  • 打赏
  • 举报
回复
谢了
kobefly 2005-04-18
  • 打赏
  • 举报
回复
贴代码

工具类型
jingbinqwe 2005-04-18
  • 打赏
  • 举报
回复
我去了头文件stdafx,加了两个"}"以下可以编译通过
//////////////////////////////////greedygiftgiver.c///////////////////////////////////////////
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdafx.h>
//////////////////////////////////struction define/////////////////////////////////////////////
struct greedygiftgiver
{
char name[10];
int getMoney,giveMoney,giveTo;
}ggg[10];

//////////////////////////////////function main////////////////////////////////////////////////

int main()
{
int np=0,i=0,j=0,k=0,giveTo=0,giveMoney=0;
char name0[10],name1[10];
FILE *fp1,*fp2;
if((fp1=fopen("/home/data/greedygiftgiver.in.txt","r"))==NULL)
{
printf("cannot open this file \'/home/data/greedygiftgiver.in.txt\'\n");
exit(EXIT_FAILURE);
}
if((fp2=fopen("/home/data/greedygiftgiver.out.txt","a"))==NULL)
{
printf("cannot open this file \'/home/data/greedygiftgiver.out.txt\'\n");
exit(EXIT_FAILURE);
}
fscanf(fp1,"%d",&np);//read data to np
for(i;i<np;i++)//read data to struct ggg
fscanf(fp1,"%s",ggg[i].name);
for(i=0;i<np;i++)
{
fscanf(fp1,"%s%d%d",name0,&giveMoney,&giveTo);
for(j=0;j<giveTo;j++)
{
fscanf(fp1,"%s",&name1);
for(k;k<np;k++)
{
if(!strcmp(name1,ggg[k].name))
ggg[k].getMoney=(giveMoney/giveTo);
if(!strcmp(name0,ggg[k].name))
{
ggg[k].giveMoney=giveMoney;
ggg[k].giveTo=giveTo;
}
}
} ///////////少了}
}///////////////少了}
for(i=0;i<np;i++)
fprintf(fp2,"%s %d\n",ggg[i].name,ggg[i].getMoney-ggg[i].giveMoney+ggg[i].giveMoney%ggg[i].giveTo);
fclose(fp1);
fclose(fp2);

return EXIT_SUCCESS;
}
greenteanet 2005-04-17
  • 打赏
  • 举报
回复
unexpected end of file found

The compiler reached the end of a source file without resolving a construct. The code may be missing one of the following elements:

A closing brace
A closing parenthesis
A closing comment marker (*/)
A semicolon
Other possible causes

The default disk drive has insufficient space for temporary files, which require about twice as much space as the source file.
An #if directive that evaluates to false lacks a closing #endif directive.
A source file does not end with a carriage return and line feed.
The following sample generates C1004:

// C1004.cpp
#if TEST
// uncomment the next line
// #endif

int main() {
}
// C1004
lfangqing2003 2005-04-17
  • 打赏
  • 举报
回复
前面是在VC++6下编的,不行,所以在KDevelop下试了一下还是不行,同样的错误。
lfangqing2003 2005-04-17
  • 打赏
  • 举报
回复
//////////////////////////////////greedygiftgiver.c///////////////////////////////////////////
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdafx.h>
//////////////////////////////////struction define/////////////////////////////////////////////
struct greedygiftgiver
{
char name[10];
int getMoney,giveMoney,giveTo;
}ggg[10];

//////////////////////////////////function main////////////////////////////////////////////////

int main()
{
int np=0,i=0,j=0,k=0,giveTo=0,giveMoney=0;
char name0[10],name1[10];
FILE *fp1,*fp2;
if((fp1=fopen("/home/data/greedygiftgiver.in.txt","r"))==NULL)
{
printf("cannot open this file \'/home/data/greedygiftgiver.in.txt\'\n");
exit(EXIT_FAILURE);
}
if((fp2=fopen("/home/data/greedygiftgiver.out.txt","a"))==NULL)
{
printf("cannot open this file \'/home/data/greedygiftgiver.out.txt\'\n");
exit(EXIT_FAILURE);
}
fscanf(fp1,"%d",&np);//read data to np
for(i;i<np;i++)//read data to struct ggg
fscanf(fp1,"%s",ggg[i].name);
for(i=0;i<np;i++)
{
fscanf(fp1,"%s%d%d",name0,&giveMoney,&giveTo);
for(j=0;j<giveTo;j++)
{
fscanf(fp1,"%s",&name1);
for(k;k<np;k++)
{
if(!strcmp(name1,ggg[k].name))
ggg[k].getMoney=(giveMoney/giveTo);
if(!strcmp(name0,ggg[k].name))
{
ggg[k].giveMoney=giveMoney;
ggg[k].giveTo=giveTo;
}
}
for(i=0;i<np;i++)
fprintf(fp2,"%s %d\n",ggg[i].name,ggg[i].getMoney-ggg[i].giveMoney+ggg[i].giveMoney%ggg[i].giveTo);
fclose(fp1);
fclose(fp2);

return EXIT_SUCCESS;
}
楼上见源代码,写得很差,不要见笑!请帮忙分析一下!谢了!
healer_kx 2005-04-17
  • 打赏
  • 举报
回复
#include <stdafx.h>
277894613 2005-04-17
  • 打赏
  • 举报
回复
遇到过,很烦的.
ysbcg 2005-04-17
  • 打赏
  • 举报
回复
你没有加
#include <stdafx.h>
sTigerwsk 2005-04-17
  • 打赏
  • 举报
回复
想来多数还是少分号了吧
zhangfjj 2005-04-17
  • 打赏
  • 举报
回复
引起这样的错误有许多原因,你最好贴上出现错误的代码来看看
xjp6688 2005-04-17
  • 打赏
  • 举报
回复
同意楼上
zengwujun 2005-04-17
  • 打赏
  • 举报
回复
大部分情况是类定义没有结束,少';'号吧
class T{...};//<--
warmage 2005-04-17
  • 打赏
  • 举报
回复
支持下 抢沙发
oyljerry 2005-04-17
  • 打赏
  • 举报
回复
需要加上预编译头文件
#include "stdafx.h"
北极猩猩 2005-04-17
  • 打赏
  • 举报
回复
楼上言之有理,这是VC6里面最常见的一个错误,如果楼主的项目选择的是MFC的项目,那么每个cpp文件都要包含stdafx.h头文件,否则就会出现这个错误。
dongpy 2005-04-17
  • 打赏
  • 举报
回复
在VC中,.cpp文件的最前面要加上 #include "stdafx.h",否则就会出现那样的问题。

64,651

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧