c++问题,编译出错
来源:百度知道 编辑:UC知道 时间:2024/06/07 09:51:00
// wu_6_001.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <iostream>
using namespace std;
bool isnumber(char);
int main()
{
char c;
while(cin>>c && c!='\n')
{
if(isnumber(c))
cout<<"you entered a digit.\n";
else
cout<<"you entered a non-digit.\n";
}
// printf("Hello World!\n");
return 0;
}
bool isnumber(char ch)
{
return ch>='0'&&ch<='9'?1:0;
}
编译显示为:
Compiling...
wu_6_001.cpp
f:\吴职钦\wu_6_001\wu_6_001.cpp(30) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.
wu_6_001.obj - 1 error(s), 0 warning(s)
//
//#include "stdafx.h"
#include <iostream>
using namespace std;
bool isnumber(char);
int main()
{
char c;
while(cin>>c && c!='\n')
{
if(isnumber(c))
cout<<"you entered a digit.\n";
else
cout<<"you entered a non-digit.\n";
}
// printf("Hello World!\n");
return 0;
}
bool isnumber(char ch)
{
return ch>='0'&&ch<='9'?1:0;
}
编译显示为:
Compiling...
wu_6_001.cpp
f:\吴职钦\wu_6_001\wu_6_001.cpp(30) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.
wu_6_001.obj - 1 error(s), 0 warning(s)
//#include "stdafx.h"
因为你把这个注释掉了。
如果你开了预编译头文件的选项, 你就必须在每个 .c .cpp文件最前面加上这个include,否则就编译错。
要是你就是不想加这个就在工程选项里关掉 预编译头文件的选择
程序没问题,你应该是建立了一个mfc或者win32项目等
应该是VC6的问题。
重装下或换其他IDE