我怎么在C++中使用"stdafx.h"?

9 浏览
0 Comments

我怎么在C++中使用"stdafx.h"?

这个问题已经在此处有答案了:

在Visual Studio中,\"stdafx.h\"用于什么?

我在我的c++代码中遇到了一个问题。当我在我的代码中写了“include \"stdafx.h\"”时,出现了错误。这是为什么?我有两张图片来更好地解释我的问题。谁能帮助我?

https://imgur.com/yfHsKD6

https://imgur.com/T6Jd3pV

这是我的代码:

#include 
#include "stdafx.h"
using namespace std;
int main()
{
int x, y,toplam=0;
cout << "1. Sayiyi Giriniz:"; cin >> x;
cout << "2. Sayiyi Giriniz:"; cin >> y;
toplam = x + y;
cout << "Sayilarin toplami:" << toplam << endl;
system("PAUSE");
return 0;
}

错误 C1083 无法打开包括文件:“stdafx.h”:没有那个文件或目录

错误 (active) E1696 无法打开源文件“stdafx.h”

admin 更改状态以发布 2023年5月23日
0
0 Comments

你的项目没有stdafx.h - 这是Visual Studio添加的。从源代码中删除它。

然后转到项目设置 -> C++ -> 预编译头,选择不使用预编译头从下拉列表中选择。

0
0 Comments

Microsoft Visual Studio及其C++编译器默认创建使用称为“预编译头”的东西的项目。早期版本使用的名称为"stdafx.h"

最新版本中文件的名称已更改,一般情况下不常用预编译头用于其他环境。

如果编译器不能找到它,则只需删除#include指令即可。

0