fatal error: iostream.h: No such file or directory

Hello all,

Finally I have started writting tiny programs in C++.
And here is my first question: I am trying to use #include <iostream.h> in a simple c++ program.
I am using cygwin and I am able to compile and execute this program and others well when I use #include <iostream>.
But when I use #include <iostream.h> I get error as:

$ g++ Test1.cpp -o Test1
Test1.cpp:1:22: fatal error: iostream.h: No such file or directory
#include <iostream.h>
^
compilation terminated.

Is this expected or am I missing something? Should .h I read that both iostream and iostream.h should work.
Here is code I have put in

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream.h>

using namespace std;

int main()
{
	float number1, number2, sum, average;
	cout << "Enter two numbers: ";	//prompt
	cin >> number1;	//Reads numbers
	cin >> number2; //from keyboard
	
	sum = number1 + number2;
	average = sum/2;
	
	cout << "Sum = " << sum << "\n";
	cout << "Average = " << average << "\n";
	
	return 0;
}
<iostream>
g++ does not come with iostream.h, only some very old versions of Borland compilers do. You should always use <iostream> these days.
The header name iostream.h dates back to the pre-standard C++ of the early 1990's.
After C++ was standardized in 1998 (as C++98), those header names were deprecated.

Some compilers may still provide the headers for backward compatibility, but you should not use them.
See the reference of this site to see what headers are available to you.
http://www.cplusplus.com/reference/

Alternatively:
http://en.cppreference.com/w/cpp/header

So in your case, you should use iostream instead of iostream.h.

Finally, you should unlearn using namespace std; because:
http://www.parashift.com/c++-faq/using-namespace-std.html
Ok, got it.
Thanks for such speedy response Mats, modoran & Catfish666.
Last edited on
Topic archived. No new replies allowed.