((Code::Blocks)) - fatal error: stdafx.h: No such file or directory

((Code::Blocks)) - fatal error: stdafx.h: No such file or directory

我正在使用 Code::Blocks 版本 16.01,我正在学习 www.learncpp.com 课程 1.3a。我的代码如下所示:

#include <iostream>
#include "stdafx.h"

int main()
{
    std::cout << "Enter a number: "; // ask user for a number
    int x = 0;
    std::cin >> x; // read number from console and store it in x
    std::cout << "You entered " << x << std::endl;
    return 0;
}

整个程序运行良好,但只有一个错误,那就是#include stdafx.h;我收到标题中列出的错误。帮助和稍微清楚的解释对我来说会很好(我显然没有经验)。

您删除#include "stdafx.h"

#include "stdafx.h" 

我们用在visual studio :).

stdafx.h 用于 Visual Studio 的预编译头文件的实现。如果你也不使用 VS

将 stdafx.h 文件从 Visual Studio 项目文件夹复制到 Code::Blocks 项目文件夹并继续构建。

如果您没有 Visual Studio 项目,请删除 #include "stdafx.h" 行。如果您没有 stdafx.h,那么很有可能里面没有您需要的东西。如果赔率对您不利,编译器会很快让您知道。