47

Possible Duplicate:
No such file iostream.h when including

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?

#include <iostream.h>


int main(){

    cout<<"Hello World!\n";
    return 0;
}
Community
  • 1
  • 1
Assasins
  • 1,593
  • 5
  • 20
  • 22

3 Answers3

69

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

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

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

Puppy
  • 144,682
  • 38
  • 256
  • 465
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
  • 1
    1970's?. was Bjarne still in high-school back then ? – WhozCraig Oct 24 '12 at 13:16
  • 11
    @J99: I never exaggerate, not in the entire history of the universe. – Kerrek SB Oct 24 '12 at 13:16
  • 1
    I think the original streams library was invented by some Jerry Schwartz in the early or mid-80s. For some reason I have 1984 stuck in my head, but I am too lazy to get D&E down from the shelf where it rots and check this. – sbi Oct 24 '12 at 20:17
11

Using standard C++ calling (note that you should use namespace std for cout or add using namespace std;)

#include <iostream>

int main()
{
    std::cout<<"Hello World!\n";
    return 0;
}
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
il_guru
  • 8,383
  • 2
  • 42
  • 51
9

You should be using iostream without the .h.

Early implementations used the .h variants but the standard mandates the more modern style.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953