Menu

Got Hello World! problem

Vendo
2008-02-21
2012-09-26
  • Vendo

    Vendo - 2008-02-21

    I am very very beginner. I am just starting learning C++ and i friend recommended this compiler
    Few minutes later i already have problems :P

    // asdf

    include <iostream>

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

    That's the program...cant be simpler and i still get an error:

    C:\Documents and Settings\Vendo\Desktop\cpp\main.cpp In function int main()': 91 C:\Documents and Settings\Vendo\Desktop\cpp\main.cppcout' undeclared (first use this function)
    (Each undeclared identifier is reported only once for each function it appears in.)

     
    • Wayne Keen

      Wayne Keen - 2008-02-21

      Short answer - check out the thread titled 'Please Read Before Posting a Question' - there is an example Hello World there.

      Longer version - C++ uses something called namespaces to keep things straight in a language that encourages using names multiple times. You did not tell the compiler what namespace to find cout etc. in.

      Wayne

       
      • Nobody/Anonymous

        It is also a very bad idea to put your code in places with spaces in their path, like your desktop.

        I encourage you to take the time to read through the "Please Read" thread, it covers a lot of
        useful material.

        Wayne

         
    • Frigo112

      Frigo112 - 2008-02-28

      You have to put ,std::cout , or, using namespace std;,I am also beginer

       
    • Nirvin

      Nirvin - 2008-03-09

      Answer : The only bug in your program is that you didn't specify the namespace to be used.

      Here is the correct version :

      // asdf

      include <iostream>

      using namespace std;
      main ()
      {
      cout <<"Hello world!";
      return 0;
      }

       
      • cpns

        cpns - 2008-03-09

        What about the implicit return type for main() !? That looks like a bug too to me.

        Why would you see the need I wonder to answer a question that was already adequately answered with a flawed response, twe weeks after it was relevant?

        Clifford

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.