初学C语言..这段程序错在哪里?

#include <stdio.h>
void main()
{
int a,b,sum;
a=123;b=456;
sum=a+b;
printf("sum is %d\n",sum);
}

错误提示:d:\visual c++ 6.0\msdev98\myprojects\7\7.cpp(12) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

错误内容是:在寻找预编译头的时候遇到了意外的文件结尾。
原因是你开了预编译头功能,但是却没有预编译头文件。
解决方法是关掉预编译头的设置。
......不过估计你不知道在哪,我手上也没有VC6

这样吧。在项目里添加"stdafx.h"和"stdafx.cpp"文件
stdafx.cpp的内容是#include "stdafx.h"

然后在你主程序最开头也加上#include "stdafx.h"

搞不定hi我
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-10-13
Visual Stdio 的安装有问题 建议换用其他的c 编译器 例如 C Free
或者 Code::Block 或者是 C++ builder
第2个回答  2009-10-13
你用的什么编译器啊,我用的DEV-C++,把void去掉就好了
第3个回答  2009-10-13
把文件另存为 .c 文件再运行
相似回答