陶大宇演过的电影:vc6.0的问题,高手请进

来源:百度文库 编辑:高考问答 时间:2024/04/30 10:14:52
我初学vc刚开始就遇到问题了
今天刚装上的vc
我新建了一个win32 console Appilcation工程名为71901
再选择“hello world”程序

#include "stdafx.h"

int main(int argc, char* argv[])
{
printf("Hello World!\n");
return 0;
}

但运行编译它就出错了 如下:

--------------------Configuration: 71901 - Win32 Debug--------------------
Compiling...
71901.cpp
d:\program files\microsoft visual studio\myprojects\71901\71901.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/71901.pch': No such file or directory
执行 cl.exe 时出错.

71901.obj - 1 error(s), 0 warning(s)

怎么回事啊?
用C++语言怎么提示出错啊
#include "stdafx.h"
#include <iostream>

int main(int argc, char* argv[])
{
cout<<"hello"<<endl;
printf("Hello World!\n");
return 0;
}
报错:
--------------------Configuration: 7192 - Win32 Debug--------------------
Compiling...
7192.cpp
G:\c代码\7192\7192.cpp(9) : error C2065: 'cout' : undeclared identifier
G:\c代码\7192\7192.cpp(9) : error C2297: '<<' : illegal, right operand has type 'char [6]'
G:\c代码\7192\7192.cpp(9) : error C2065: 'endl' : undeclared identifier
执行 cl.exe 时出错.

7192.obj - 1 error(s), 0 warning(s)

再补充:
加了后还错:
--------------------Configuration: 71902 - Win32 Debug--------------------
Compiling...
71902.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\71902\71902.cpp(2) : error C2871: 'std' : does not exist or is not a namespace
执行 cl.exe 时出错.

71902.obj - 1 error(s), 0 warning(s)

no precompiled header会降低编译的速度。

你打开stdafx.cpp,ctrl+f7编译一下,
然后rebuild all,应该可以了。

后一个程序在#include <iostream>下一行加上
using namespace std;

你用的是iostream还是iostream.h?

另外,你如果是C++的初学者,就不要用VC了,换个其他的编译器吧,用VC对你的提高没有好处

没安装,说个大概吧。project setting里面的 c/c++ 选项卡

在combo里面找到 precompiled header

选择 no precompiled header 即可

dfsh