0

I am using GCC 4.6.3:

gourab@gourab-RV509:~$ g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

My program results in the following compilation error:

gourab@gourab-RV509:~$ g++ ArrayInput.cpp
ArrayInput.cpp:1:21: fatal error: iostream.h: No such file or directory

How can I fix it?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
grv.giit
  • 37
  • 1
  • 1
  • 3
  • Typically you want to use the `` includes. Perhaps they're already on the default include path? – Rob I Jan 02 '13 at 14:27
  • after resolving the issue and recompiling i get this error:- gourab@gourab-RV509:~$ g++ ArrayInput.cpp ArrayInput.cpp: In function ‘int main()’: ArrayInput.cpp:5:2: error: ‘cout’ was not declared in this scope ArrayInput.cpp:5:2: note: suggested alternative: /usr/include/c++/4.6/iostream:62:18: note: ‘std::cout’ ArrayInput.cpp:8:5: error: ‘cin’ was not declared in this scope ArrayInput.cpp:8:5: note: suggested alternative: /usr/include/c++/4.6/iostream:61:18: note: ‘std::cin’ – grv.giit Jan 02 '13 at 14:33
  • @grv.giit Which book are you using ? – asheeshr Jan 02 '13 at 14:38
  • @Lightness Races in Orbit: sorry to say you but i have coding and programming experience in windows platform . I'm new to Linux. That's why i just got confused many times... :) – grv.giit Jan 02 '13 at 14:49
  • @grv.giit: It's just the same in Windows. – Lightness Races in Orbit Jan 02 '13 at 14:51
  • @AshRj:- thanks for the concern friend !! i am using my college notes of C++ OOPS which is having academic syllabus of our university.. :) – grv.giit Jan 02 '13 at 14:54
  • @grv.giit Get a proper book. Those notes will get you through the semester but wont help you beyond that. Its better if you use a proper book, referring to the notes only for the topics to study. And DONT go for any Indian authored textbook. – asheeshr Jan 02 '13 at 15:13
  • http://members.gamedev.net/sicrane/articles/iostream.html :- This link solved many issues i got !! a thumps up to all of you... – grv.giit Jan 02 '13 at 15:16
  • Possible duplicate of [Why can't g++ find iostream.h?](https://stackoverflow.com/questions/13103108/why-cant-g-find-iostream-h) – phuclv Aug 12 '18 at 11:27

2 Answers2

11

iostream.h has not existed in C++ since some time before the language was standardised back in 1998.

That's more than fifteen years ago.

Do the following:

  • Throw away your reading material
  • Get a decent book
  • #include <iostream>no .h
Community
  • 1
  • 1
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
2

You want to include iostream. iostream.h was present in Stroustrup's C++:

The original iostream library was written to challenge the claim that a terse, type safe I/O system needed special language support. 1 It was developed at Bell Labs by Bjarne Stroustrup and shipped with the original C++ compiler, CFront and described in the first edition of Stroustrup's The C++ Programming Language. This version of the iostream library lived in the headers iostream.h, fstream.h and so on.

The Standard C++ has the headers without the .h, so you want to:

#include <iostream>

Here is an article that discusses this.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
asheeshr
  • 4,088
  • 6
  • 31
  • 50