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>
usingnamespace 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;
}
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/