C++ 致命错误:iostream.h 没有这样的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13049978/
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 16:54:52  来源:igfitidea点击:

fatal error: iostream.h no such file or directory

c++codeblocks

提问by Assasins

Possible Duplicate:
No such file iostream.h when including

可能的重复:
包含时没有这样的文件 iostream.h

Even after naming the source file with .cpp extension. my compiler gives this error, both in command prompt and Codeblocks. How can I fix this issue?

即使在使用 .cpp 扩展名命名源文件之后。我的编译器在命令提示符和代码块中都给出了这个错误。我该如何解决这个问题?

#include <iostream.h>


int main(){

    cout<<"Hello World!\n";
    return 0;
}

回答by Kerrek SB

That header doesn't exist in standard C++. It was part of some pre-1990s compilers, but it is certainly not part of C++.

该头文件在标准 C++ 中不存在。它是 1990 年代之前的一些编译器的一部分,但它肯定不是 C++ 的一部分。

Use #include <iostream>instead. And all the library classes are in the std::namespace, for ex­am­ple std::cout.

使用#include <iostream>来代替。并且所有的库类都在std::命名空间中,例如std::cout.

Also, throw away any book or notes that mention the thing you said.

另外,扔掉任何提到你说过的话的书或笔记。

回答by il_guru

Using standard C++ calling (note that you should use namespace stdfor coutor add using namespace std;)

使用标准的C ++调用(请注意,您应该使用命名空间STDCOUT或增加使用空间std;

#include <iostream>

int main()
{
    std::cout<<"Hello World!\n";
    return 0;
}

回答by paxdiablo

You should be using iostreamwithoutthe .h.

你应该使用iostream没有.h

Early implementations used the .hvariants but the standard mandates the more modern style.

早期的实现使用了这些.h变体,但标准要求更现代的风格。