代码::阻止编译错误

Code::Blocks Compilation Errors

本文关键字:错误 编译 代码      更新时间:2023-10-16

我在代码::块方面遇到了一些问题,这是编译后/编译时的输出;

3|iostream: No such file or directory|
4|error: syntax error before "namespace"|
|In function `main':|
8|error: `cout' undeclared (first use in this function)|
8|error: (Each undeclared identifier is reported only once|
8|error: for each function it appears in.)|
||=== Build finished: 5 errors, 1 warnings ===|

我的代码如下所示;

// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
  cout << "Hello World!";
  return 0;
}

您必须创建控制台C++项目。

文件->新建项目->控制台应用程序->C++。

它将设置变量和链接器选项,如基本库。

cout问题是因为你应该说

using namespace std;

iostreams的问题可能是您需要在工具链中设置MINGW的路径。您可以从设置->编译器和调试器设置->全局编译器设置->工具链可执行文件菜单/选项卡访问此项。在这里选择安装MINGW的部件,并由其负责。