我的vc6.0不能用

来源:百度知道 编辑:UC知道 时间:2024/06/30 06:11:00
我的VC不能用
写个小程序
main()
{ int i,s=1;
for (i=1;i<50;i++)
if(!(i%5)&&!(i%3)) s+=i;
printf("%d\n",s);
}
出现--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
g:\vc\vc6\vc6cn\common\msdev98\bin\cpp1.cpp(5) : error C2065: 'printf' : undeclared identifier
g:\vc\vc6\vc6cn\common\msdev98\bin\cpp1.cpp(6) : warning C4508: 'main' : function should return a value; 'void' return type assumed
Error executing cl.exe.

Cpp1.exe - 1 error(s), 1 warning(s)
不知道哪里错了帮帮我

一、error C2065: 'printf' : undeclared identifier
加入头文件可以解决错误:#include <stdio.h>
二、warning C4508: 'main' : function should return a value; 'void' return type assumed
在main前面加上函数类型void可以去掉警告: void main()

#include <stdio.h>
main()
{
int i,s=1;
for (i=1;i<50;i++)
if(!(i%5)&&!(i%3)) s+=i;
printf("%d\n",s);
}
你没有头文件当然会错!!!!!!!!1

就是4for1one9night说的那样

不知道你的代码的最前端是否有:
#include stdafx.h
#include stdio.h
两个头文件.