C++ 致命错误 C1083:无法打开包含文件:“iostream”:没有这样的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15181537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:07:37  来源:igfitidea点击:

fatal error C1083: Cannot open include file: 'iostream': No such file or directory

c++windowsvisual-studio-2010includeiostream

提问by syuja

I've reinstalled Visual Studio 2010 Professional several times to try to get it to work. I had to uninstall Visual Studio 2012 Professional because it wasn't compiling something we did in class.

我已多次重新安装 Visual Studio 2010 Professional 以尝试使其正常工作。我不得不卸载 Visual Studio 2012 Professional,因为它没有编译我们在课堂上做的事情。

I completely uninstalled everything including SQL Server..

我完全卸载了包括 SQL Server 在内的所有内容。

I went to VC/include and the iostream header file is not there.

我去了 VC/include 并且 iostream 头文件不在那里。

#include <iostream>

int main () {

cout << "hello";

system ("PAUSE");
return 0;
}

This is all I'm trying to do because nothing else is working.

这就是我正在尝试做的所有事情,因为没有其他任何工作。

It's really driving me crazy because I need to get it working so that I can do my project!!!

这真的让我发疯,因为我需要让它工作,这样我才能完成我的项目!!!

Every time I do; new project => empty project => add an item to source =>.cpp

每次我这样做;新项目 => 空项目 => 将项目添加到源 =>.cpp

I'm running windows 8.

我正在运行 Windows 8。

It just says Error cannot open source file Also, error cout identifier is undefined....

它只是说错误无法打开源文件此外,错误 cout 标识符未定义....

I'm wondering if I should do a system restore? Or if I should just completely reinstall windows 8 from my recovery media?

我想知道我是否应该进行系统还原?或者我是否应该从我的恢复媒体完全重新安装 Windows 8?

回答by Games Brainiac

One problem is that you did not include the namespace std.

一个问题是您没有包含 namespace std

This is what your code should look like:

你的代码应该是这样的:

#include <iostream>
using namespace std;

int main (void) {
    cout << "hello" << endl;
    system("pause");
    return 0;
}

or you could have done something like this: std::cout << "Hello" << std::endl;

或者你可以做这样的事情: std::cout << "Hello" << std::endl;

This may be a problem because you did not set your environment to C++. This is how you do it:

这可能是一个问题,因为您没有将环境设置为 C++。这是你如何做到的:

  1. Go to Tools> Import and Export settings. If you cannot find it, just search for it in Quick Search
  2. Then go to reset all settings.
  3. Then simply select "Visual C++"
  4. Restart.
  1. 转到工具>导入和导出设置。如果找不到,只需在快速搜索中搜索即可
  2. 然后去重置所有设置。
  3. 然后只需选择“Visual C++”
  4. 重新开始。

That should do the trick. If it does not, you might consider re-installing Visual C++ itself. For VS 2012. If that does not work, then re-install the program.

这应该够了吧。如果没有,您可以考虑重新安装 Visual C++ 本身。对于VS 2012。如果这不起作用,则重新安装该程序。

回答by Bhanu Karthik

if it is problem with visual studio 2012, install thisupdate.

如果 Visual Studio 2012 有问题,请安装更新。