In some c++ source code I wrote this:

#include <iostream.h>
using namespace std;
error: iostream.h: No such file or directory

I compiled it using g++.

But when I changed it to
#include <iostream>

it started working.

Why?

Recommended Answers

All 2 Replies

<iostream.h> is the pre-standard version if <iostream>. Modern compilers are quickly dropping pre-standard support. Note that a .h extension is not implied if you omit it. The two header names are completely different.

Apparently what I've read on another site is that including iostream.h has be deprecated from gcc(3.x) and newer. I believe in the older versions iostream with no suffix used to simply include iostream.h itself so you could include iostream.h in your program with no errors. now all of the declarations that were in iostream.h have been moved to the files istream and ostream and the file iostream simply includes these.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.