I have a problem compiling a simple "Hello World" Statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hrstissiaopai
    New Member
    • Mar 2013
    • 27

    I have a problem compiling a simple "Hello World" Statement

    I am using a book to learn C++. I wrote the code that does a "Hello World" statement, and when I click "Compile" nothing happens. I am using DevC++.
  • divideby0
    New Member
    • May 2012
    • 131

    #2
    Were there any compiler errors? If so, what are they? If not, are you sure the program didn't close before you were able to see its output?

    A crude way to keep the window open is to use getchar.

    Code:
       // your code
       getchar();
       return 0;
    }
    Another idea would be to check in the project folder and see if you've got an executable; if you do, trying running it from the command line.

    Comment

    • whodgson
      Contributor
      • Jan 2007
      • 542

      #3
      Did you save the code as a .cpp file before compiling?

      Comment

      • hrstissiaopai
        New Member
        • Mar 2013
        • 27

        #4
        @whodgson yes, I did.

        Comment

        • monika5592
          New Member
          • Mar 2013
          • 2

          #5
          use getch() just before return statement of main().
          Code:
          main()
          {
          //your code
          getch();
          return;
          }
          or use system("PAUSE") like
          Code:
          main()
          {
          //your code
          system("PAUSE");//note pause is written in capital letters
          return;
          }
          Last edited by Niheel; Mar 17 '13, 05:10 PM. Reason: fixed code issues

          Comment

          Working...