cout not working

Jun 22, 2011 at 8:39pm
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;
}



Jun 22, 2011 at 9:02pm
Hi GeckoLink,

There's nothing wrong with that code, have you tried compiling on a different computer?
Jun 22, 2011 at 9:04pm
Is this your first run with that IDE? You may have to reinstall it.
Jun 22, 2011 at 9:31pm
your code is perfect. try running it wit f9
Jun 22, 2011 at 11:04pm
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 Jun 22, 2011 at 11:04pm
Jun 23, 2011 at 12:37am
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 Jun 23, 2011 at 12:39am
Jun 23, 2011 at 1:31am
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 Jun 23, 2011 at 1:31am
Jun 23, 2011 at 7:13am
closed account (zb0S216C)
Well, I know what I need to learn next :)P

Wazzak
Jun 23, 2011 at 2:07pm
Thanks for the help people, I tried a different compiler on another computer and It worked fine! Thanks again!
Last edited on Jun 23, 2011 at 2:08pm
Topic archived. No new replies allowed.