## Recommended Posts

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 on other sites
Hey,

How about trying #include < iostream > .

##### Share on other sites
This will solve it,

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

using namespace std;

directly under that.

Should work then

##### Share on other sites
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 on other sites
Hi,

thanx a lot it worked

bye

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628390
• Total Posts
2982410

• 10
• 9
• 19
• 24
• 11