Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey i have dev c++ and in just the simplest app i got problems. my app is a basic one from a book, open a window and display the classic "hello world". now it has a file it needs calles iostream.h in dev c++ is it io.h or iostream (its a url protocol). Secondly i tried both of them and the compiler givves out that "cout" is undecleared. here is the simple app
#include <iostream>
int main()
{
cout <<"Hello World!\n";
return 0;
}or there is the second one
#include <io.h>
int main()
{
cout <<"Hello World!\n";
return 0;
}i get the same error in both. even java with forte for java 4 was a bit diffrent but its ok now
Im only 14, so dont blame me
AMD athlon xp 2000+
ECS K7S5A Pro
512 MB DDR ram
Sapphire atlantis 9200se
8 GB quantum fireball
30 GB Maxtor Diamondmax 60 GB Maxtor Diamondmax

Sounds like it's not finding your iostream.h file. Look in the compiler options under the directories tab and there you can tell it which directory to search for include files when compiling.
If you don't know which directory that is, use your Windows find tool to search for "iostream.h" I would just tell you which directory it is in but I use Dev C++ with Borland C++ builder so my include directory will be different than yours.

I don't know about dev c++ but the standard way to do it is this:
#include <iostream.h>
int main()
{
cout <<"Hello World!" << endl;
return 0;
}The new way with namespaces has two variations:
Variation 1:
#include <iostream>
using namespace std;int main()
{
cout <<"Hello World!" << endl;
return 0;
}Variation 2:
#include <iostream>
int main()
{
std::cout <<"Hello World!" << std::endl;
return 0;
}

add using namespace std below the #include directive or append each cout with std::cout. Alternatively, you could also declare using std::cout after the include. That's three different ways to do a similar thing, but each one operates on a different scope of classes.
using namespace std
(declares all classes in std)
using std::cout
(explicity declares cout in all instances)
std::cout
(explicitly declares class cout in one instance)Declaring the namespace makes iostream declarations accessible.
iostream.h is the ANSI C++ standard file, but the file extension (.h, for header) was deprecated. io.h is an OS library (not necessarily standard at all).
Be sure to check the compiler's include path, per Fozzie's suggestion.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |