-
Problem with cout
I'm new to this so I was starting the tutorial and on lesson one I found something wrong. I found out first mistake was <iostream.h>
Program: Test.cpp
#include <_iostreamP.h>
int main()
{
cout<<"HEY, you, I'm alive! Oh, and Hello World!";
return 0;
}
Once I compiled it I got this error message:
In function 'int main()':
Test.cpp(7) Error: 'cout' undeclared (first use this function)
Test.cpp(7) Error: (Each undeclared indentifier is reported only once for each function in appears in)
Thanks for all your help. Trevor
-
The 'include' is <iostream.h>.
Or, #include <iostream> coupled with 'std::cout' vice 'cout', i.e.:
Code:
#include <iostream>
int main()
{
std::cout << "HEY, you, I'm alive! Oh, and Hello World!";
return 0;
}
-Skipper
-
Thank you Skipper That worked thanks again. Trevor
-
*Grabs fire suit*
The best way is like this:
Code:
#include <iostream.h>
int main()
{
cout << "Hello";
return 0;
}
-
face_master, if by best you mean non-standard then you are correct. skipper's example is correct. You can also do this:
Code:
#include <iostream>
int main()
{
using std::cout;
cout << "HEY, you, I'm alive! Oh, and Hello World!";
cout << "I'm using cout without typing 'std::' every time";
return 0;
}