注册 登录
编程论坛 VC++/MFC

'stdafx.h'头文件打开问题

燕过风 发布于 2010-05-17 17:51, 1441 次点击
在编译的过程中,每次将'stdafx.h'添加后,都出现以下出错信息“fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
执行 cl.exe 时出错.”
当我把这个头文件给删除后,调试、运行都是没有问题的。谁能详细解释一下原因?有什么解决办法?
程序代码:
#include"stdafx.h"
#include<iostream.h>
void Swap(int &a,int &b);
void Swap(int &a,int &b)
{int t;
t=a;a=b;b=t;}
int main(int argc,char*argv[])
{int x=8,y=10;
cout<<"x="<<x<<" y="<<y<<endl;
Swap(x,y);
cout<<"x="<<x<<" y="<<y<<endl;
cin>>x;
return 0;
}
这是一个其中的例子

[ 本帖最后由 燕过风 于 2010-5-17 17:55 编辑 ]
5 回复
#2
幽园香客2010-05-17 21:49
stdafx.h是MFC中自动生成的一个文件。如果没用到这个头文件,何必包含呢?
#3
smithalive2010-05-22 14:45
这个问题我也遇到过,怎么解决?
#4
smithalive2010-05-22 14:47
NMAKE : fatal error U1052: file 'stdafx.mak' not found
出现这样的怎么解决?
#5
dyh8399110102012-12-24 18:35
我也碰到了,求哥们解决
#6
我心依旧13142013-01-03 16:10
我也是,fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory,求高手帮忙解决
1