【发布时间】:2016-07-17 07:59:34
【问题描述】:
我正在使用 Visual Studio 2015 在 C++ 中编写一个简单的程序,当我 #include <iostream> 时,我得到了一堆错误,如下图所示:
我的代码可以在下面和图片中找到。
// FirstProject.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
int main()
{
std::cout << "Hello World!";
int pause;
pause = 0;
std::cin >> pause;
return 0;
}
【问题讨论】:
-
从该错误列表的外观来看,您的包含路径不包含 C++ 标准库头文件。
-
这将是 stdafx.h 头文件中的错误。代码的其他所有内容对我来说都很好。
-
@Swemoph 你说得对,我调查了一下,发现包含文件时出现两个错误 (#include
#include ) // 无法打开源文件,但我是c++ 新手,所以我不明白为什么会发生这种情况,有什么想法吗? -
从您的 FirstProject.cpp 文件中删除
#include "stdafx.h"。您无法访问您提到的文件的源 - 它们在编译器中。 -
尝试从项目中删除所有你不使用的文件,所以
stdafx.cpp、stdafx.h和targetver.h。然后它应该编译。如果不直接创建一个新的空 c++ 控制台应用程序
标签: c++ visual-studio-2015 iostream