C语言,编译没问题,但运行出错

zhao531751268 2012-09-27 04:51:30
#include<stdio.h>
int main()
{
int age;
printf("age代表年龄:");
scanf("%d",&age);
printf("\nage=%d\n",age);
return 0;
}
编译没出错 运行 就有一个错误 怎么回事啊
...全文
2827 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
max_min_ 2012-09-28
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

--------------------Configuration: m - Win32 Debug--------------------
Compiling...
m.c
D:\VC\VC\Microsoft Visual Studio\MyProjects\m\m.c(17) : fatal error C1004: unexpected end of file found
Err……
[/Quote]

代码最后一行 再加一行空格 试试
菜鸟De渴望 2012-09-28
  • 打赏
  • 举报
回复
我觉得这个是没错的,但是你弄了个返回0;输出以后,你又返回一个假,才出错吧
zhao531751268 2012-09-28
  • 打赏
  • 举报
回复
我忘了 把另一个程序 加“/* */”了 所以这个 程序就出不来了
wanglu343280746 2012-09-28
  • 打赏
  • 举报
回复
代码没问题。是不是工程建错了
「已注销」 2012-09-28
  • 打赏
  • 举报
回复
VS的问题,使用了预处理编译的那个啥啥啥,而且未包含“stdafx.h”(好像是这么写的)
赵4老师 2012-09-28
  • 打赏
  • 举报
回复
偶遇到类似问题都是用
“每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。”
的方法解决的。
didijiji 2012-09-28
  • 打赏
  • 举报
回复
怎么解决的?
[Quote=引用 10 楼 的回复:]

OK 问题 已解决
[/Quote]
dodoline 2012-09-28
  • 打赏
  • 举报
回复
控制台程序不是win32
gfvera 2012-09-28
  • 打赏
  • 举报
回复

我是按照这个方法来修改,修改后就恢复了

打开vc界面 点击VC“TOOLS(工具)”—>“Option(选择)”
—>“Directories(目录)”重新设置“Excutable Fils、Include Files、
Library Files、Source Files”的路径。很多情况可能就一个盘符的不同
(例如你的VC装在C,但是这些路径全部在D),改过来就OK了。


如果你是按照初始路径安装vc6.0的,路径应为:
executatble files:
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin
C:\Program Files\Microsoft Visual Studio\VC98\BIN
C:\Program Files\Microsoft Visual Studio\Common\TOOLS
C:\Program Files\Microsoft Visual Studio\Common\TOOLS\WINNT

include files:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE

library files:
C:\Program Files\Microsoft Visual Studio\VC98\LIB
C:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB

source files:
C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\CRT\SRC

如果你装在其他盘里,则仿照其路径变通就行(我就是装在D盘)。
关键是microsoft visual studio\ 后面的东西要相同。
本人深受其害,重装多次不管用,上面中文部分为高手借鉴,
下面路径为本人深思所得,终于解决。与君分享。


vc中出现“没有找到mspdb60.dll文件”时:
将C:\Program Files\Microsoft Visual Studio 6\Common\MSDev98\Bin下的mspdb60.dll
文件拷贝到C:\Program Files\Microsoft Visual Studio 6\VC98\Bin目录下即可
AndyZhang 2012-09-28
  • 打赏
  • 举报
回复
单步调试,什么问题都能解决
zhao531751268 2012-09-27
  • 打赏
  • 举报
回复
OK 问题 已解决
Qiaorui 2012-09-27
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/en-us/library/4exw7xyc(v=vs.71).aspx
Fatal Error C1004

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
Qiaorui 2012-09-27
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]
在文件末尾留一行空格再试试
[/Quote]
gcc编译器存在这个问题,VC应该不会。

以上贴出已经是完整代码的话,还真不知道怎么回事。
ouPuso 2012-09-27
  • 打赏
  • 举报
回复
在文件末尾留一行空格再试试
自信男孩 2012-09-27
  • 打赏
  • 举报
回复
难道是里面有中文输入。
zhao531751268 2012-09-27
  • 打赏
  • 举报
回复
--------------------Configuration: m - Win32 Debug--------------------
Compiling...
m.c
D:\VC\VC\Microsoft Visual Studio\MyProjects\m\m.c(17) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

m.exe - 1 error(s), 0 warning(s)
自信男孩 2012-09-27
  • 打赏
  • 举报
回复
未发现错误哦。
zhao531751268 2012-09-27
  • 打赏
  • 举报
回复
有一个 错误 提示
Qiaorui 2012-09-27
  • 打赏
  • 举报
回复
MinGW环境下编译、运行通过,没有错误?错误提示呢?
qt228186471 2012-09-27
  • 打赏
  • 举报
回复
运行了,没有任何问题,楼主看看是不是输入不是整数。

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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