Archived

This topic is now archived and is closed to further replies.

Easy errors I don't understand...

This topic is 5578 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include <iostream.h>

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

You forgot using namespace std;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oh, wait, you don''t need it. Something wrong with your VC++

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
and don''t forget to put this under the include
using namespace std;

Share this post


Link to post
Share on other sites