c++中出现的cout问题
在VC6中运行cout结果出错,具体如下:
#include<iostream.h>
void main()
{
cout<<"hello\n";
}
结果是:
-Configuration: 1 - Win32 Debug--------------------
Compiling...
1.c
D:\C语言程序\1.c(4) : error C2065: 'cout' : undeclared identifier
D:\C语言程序\1.c(4) : error C2297: '<<' : illegal, right operand has type 'char [7]'
执行 cl.exe 时出错.
1.exe - 1 error(s), 0 warning(s)
我网上查 有人说说用<iostream>
using namespace std;
所以我输入:
#include<iostream>
using namespace std;
void main()
{
cout<<"hello\n";
}
结果是:------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.c
d:\vc6\vc6\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!"
执行 cl.exe 时出错.
1.exe - 1 error(s), 0 warning(s)
最后我想说的就是一般像if,int等输进去是会变成蓝色,可是我的cout不会变色(其他可以)
希望高手指点指点,谢谢
还有我在百度上问了,他们的回答是
请使用标准ANSI C++语法:
#include<iostream>
using namespace std;
int main()
{
cout<<"hello\n";
return 0;
}
if和int为系统保留字,cout是一个类,还有,你把你的文件扩展名改成cpp
他们软件上就行,我的软件上就是不行,我的软件怎么了?