compilation errors in c++

Asked by prasad.ram

hai iam prasad while compiling a c++ program it gives error like "fatal error: iostream.h: No such file or directory" i would like to know what is the reason?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
Eliah Kagan
Solved:
Last query:
Last reply:
Revision history for this message
Best Eliah Kagan (degeneracypressure) said :
#1

Including the header iostream.h is no longer standards-compliant C++ (i.e. your code is wrong, though in the past it was not considered to be wrong). If this is a program that you are writing, you should change the line that says

#include <iostream.h>

to say

#include <iostream>

instead. The same goes for the other C++ headers. If the header files are not from C, they shouldn't have the .h extension.

If they are from C (for example, stdio.h), then you can choose to give them to .h extension (in which case their identifiers are declared in the global namespace), or you can choose to leave off the .h extension but prefix the names with "c" (like "#include <cstdio>"), in which case their identifiers are declared in the "std" namespace (so the names they declare must be prefixed with std:: or given global scope with a using statement or using directive). Note that macros are always of global scope (so if you had "#include <cassert>", for example, you wouldn't replace "assert" with "std::assert").

If this is not your own program, but occurs when you are compiling software from source (for example, if you downloaded and unpacked a file with an extension like .tar, .tar.gz, .tar.bz2, .tar.xz, etc., ran ./configure, and then this error occurred when you ran make), then please post *all* the text from the Terminal (Edit > Select All; Edit > Copy, and paste it here).

Please feel free to post again if you have anymore problems.

Revision history for this message
prasad.ram (prasad-ram126) said :
#2

thank you for giving me a valuable answer