Easy errors I don't understand...

Started by
5 comments, last by Cinnamon 21 years, 7 months ago
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]
Advertisement
#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
}

You forgot using namespace std;
Oh, wait, you don''t need it. Something wrong with your VC++
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
-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.
and don''t forget to put this under the include
using namespace std;
ok it worked! I saved the work with the extension .cpp

thank you!

This topic is closed to new replies.

Advertisement