cout not working

Hello I am fairly new to the c++ environment and I tried writing a simple Hello world application (see code block) however I got a error message saying that cout was undeclared.... Please help! Thanks in advance!


1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

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



Hi GeckoLink,

There's nothing wrong with that code, have you tried compiling on a different computer?
Is this your first run with that IDE? You may have to reinstall it.
your code is perfect. try running it wit f9
Your compiler could be corrupted or the settings could be off. Try restarting the IDE, and if that doesn't work possibly re-installing it. Troubleshooting it could be worth it if the IDE takes a long time to download. I had a problem like that with Code::Blocks and a re-install fixed it.
Last edited on
closed account (zb0S216C)
GeckoLink wrote:
I got a error message saying that cout was undeclared

Since it's isolated to cout, perhaps your include directories aren't configured properly. If your linker can't find <iostream> it won't know what std is, resulting an undefined cout. I don't think it's the compiler as it's one of the linkers jobs to link the files together( Linker is self-explanatory ). Double-check your directory configurations.

I could be wrong. It could be your IDE, or your compiler could be a bit thick and not realize that cout is a valid statement within the code posted.

It would also help if you specified you IDE.

Wazzak
Last edited on
Isn't it the preprocessor that includes headers, and the compiler that compiles all the code in the CPP? I don't see what the linker has to do with preprocessor directives, or why he wouldn't get an error if it couldn't find <iostream>...
Last edited on
closed account (zb0S216C)
Well, I know what I need to learn next :)P

Wazzak
Thanks for the help people, I tried a different compiler on another computer and It worked fine! Thanks again!
Last edited on
Topic archived. No new replies allowed.