Easy errors I don't understand...
I use Microsoft Visual C++ 6.0. I did a lot of programs that used #include <stdio.h> and they worked perfectly. Now, I tried to follow some exemples on www.cplusplus.com and they don't work at all! Is someone can indicate me what's wrong? I'm a began to study C and C++ since last week. I really want to improve my skill. Here's the code;
#include <iostream.h>
int main ()
{
cout << "Hello World!";
return 0;
}
Here's the error;
Compiling...
test.c
C:\Windows\Bureau\language C\ghkgjh.c(5) : error C2065: 'cout' : undeclared identifier
C:\Windows\Bureau\language C\ghkgjh.c(5) : error C2297: '<<' : illegal, right operand has type 'char [13]'
Error executing cl.exe.
ghkgjh.obj - 2 error(s), 0 warning(s)
[edited by - cinnamon on September 9, 2002 3:27:01 PM]
September 09, 2002 02:39 PM
#include <iostream.h>
int main ()
{
cout << "Hello World!";
return 0;
}
You forgot using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
You forgot using namespace std;
I have no idea what the problem is. Are you sure you''re compiler''s set up right, and that you''re doing a console project?
As the AP said, you''re not doing "using namespace std;" but technically you''re not required to to get a working app. That, and I copied and pasted it directly into a console project in VC++ 6.0, and it compiled fine.
Check your settings, that''s all I can say.
-Arek the Absolute
As the AP said, you''re not doing "using namespace std;" but technically you''re not required to to get a working app. That, and I copied and pasted it directly into a console project in VC++ 6.0, and it compiled fine.
Check your settings, that''s all I can say.
-Arek the Absolute
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
Hmmm...this is probably a long-shot, but you might want to change your file from ghkgjh.c to ghkgjh.cpp. It probably doesn''t matter, but some compilers use .c to indicate C programs and .cpp/.cxx to designate C++ programs.
Another thing you might want to try is changing
#include <iostream.h>
to
#include <iostream>
Using .h for system header files is deprecated.
John.
Another thing you might want to try is changing
#include <iostream.h>
to
#include <iostream>
Using .h for system header files is deprecated.
John.
September 09, 2002 02:58 PM
and don''t forget to put this under the include
using namespace std;
using namespace std;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement