Sign in to follow this  
Buzz1982

no iostream.h in Visual Studio 2003(please help)

Recommended Posts

Buzz1982    122
Hi, I m using visual studio 2003 for the first time. Before that i was using visual studio 6. In VS 2003 i m having this problem that when i created a console application in C++ and included iostream.h to use the 'cout' the compiler gives this error. f:\c++\again2\again2.cpp fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory I also looked in the include directory of the VC++ but i didn't found any header file named iostream.h, however some other file also named iostream exist but with no .h extension. I am confused at this point so if any one know what is the problem and how to solve it then please reply as soon as possible. thanks alot bye

Share this post


Link to post
Share on other sites
Mulligan    378
This will solve it,

Change all standard headers (like iostream.h) to <iostream>

then add

using namespace std;

directly under that.

Should work then

Share this post


Link to post
Share on other sites
petewood    819
The standard headers (without .h) put all their stuff into a namespace called std. So <vector> and <iostream> and <string>, etc, all have their functions, classes and objects defined in namespace std. To make use of them you have to do one of three things:

//1) name explicitly, e.g,
std::string person;
std::cin >> person;
std::cout << "hello ";
std::cout << person;

//2) bring the name into the current scope, e.g,
using std::cout;
std::string person;
std::cin >> person;
cout << "hello ";
cout << person;

//3) bring everything from the namespace into scope, e.g,
using namespace std;
string person;
cin >> person;
cout << "hello ";
cout << person;


These only introduce names from the headers that you have included.

On the whole, the best practice is to only include what is needed and to never put any of these using statements into your own header files.

So you'd explicitly qualify in your headers and in .cpp functions (or possibly put using std::cout in the scope of the function). Usually
using namespace std;
is used in example code because it is shorter and doesn't distract from the main point of the example. However, it's not best practice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this