Menu

where is the message?

2008-07-09
2012-09-26
  • mark belcher

    mark belcher - 2008-07-09

    I just started programming and I did my first basic one the "Hello World!" one and for some reason after I am done compiling I open my hello.exe file and I hit find results and it doesn't have a message at at all here is the project
    #include <iostream>

    int main()
    {
    std::cout << "Hello World!\n";
    return 0;
    }

    if anyone has a solution to my problem please answer

     
    • Wayne Keen

      Wayne Keen - 2008-07-09

      The answer to your question, and many more, can be found in the thread titled (not accidentally) "Please Read Before Posting a Question". Please check it out.

      Wayne

       
    • Stanis Kiadidi

      Stanis Kiadidi - 2008-07-13

      Hi, Mark.
      I'm new to programming too but let me try and help here. I don't know the compiler you are using but I used Dev-C++ 4.9.9.2 Beta to write the "Hello, World!" program and it worked for me (on Windows Vista Home Edition).
      My code went like this:

      include <iostream.h>

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

      I compiled the program, ran it and a window just splashed and disappeared. I now used the command prompt and ran it and I could now see the message "Hello, World!".

      Here are the steps I took:
      1. Go to command prompt (On XP, click Start --> Run then type cmd in the box)
      2. type: cd \ to go to the C:\&gt; or root directory ( note the space between cd and )
      3. type: cd dev-cpp and press "Enter" to go to the Dev-C++ directory (I saved my file here) or go to the directory where you saved your file.
      4. type the name of the compiled file (in my case "hello") and hit enter; you'll see the message just below this line.

      Another way to see the message after compiling it and running it is to add this piece of code to your program - cin.get(); - just before your return 0; The above code will become like this:

      include <iostream.h>

      int main()
      {
      cout << "Hello, World!";
      cin.get(); //this is the new line I have added
      return 0;
      }

      You can find these tips here:
      http://www.cprogramming.com/compiler.html
      http://www.cprogramming.com/close.html

      I hope it was helpful to you.

       
      • Wayne Keen

        Wayne Keen - 2008-07-13

        Stanis,

        Please stop answering questions until you know a little better what you are
        doing.

        iostream.h has been deprecated since 1998, take some time and look how header
        notation changed when the ANSI standard for C++ came about.

        Wayne

         

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.