the cmd window close!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • batistakis
    New Member
    • Oct 2006
    • 6

    the cmd window close!

    when i execute c program i cant even see the results in Dev C/C++,cause the command promt window automatically close!i figured the scanf trick but ....!Can anyone help please
  • apusateri
    New Member
    • Oct 2006
    • 27

    #2
    Originally posted by batistakis
    when i execute c program i cant even see the results in Dev C/C++,cause the command promt window automatically close!i figured the scanf trick but ....!Can anyone help please
    Have you tried system("pause") ?

    Comment

    • zahidkhan
      New Member
      • Sep 2006
      • 22

      #3
      Originally posted by apusateri
      Have you tried system("pause") ?

      use getch()

      Comment

      • batistakis
        New Member
        • Oct 2006
        • 6

        #4
        ok friends!thanks! i used the system("PAUSE") AND its ok!

        Comment

        • vninja
          New Member
          • Oct 2006
          • 40

          #5
          another thing (maybe i'm thinking too simply) but are you running with the debugger on? if you are and you don't have any inputs then the cmd wndw will close after the last execution of code.
          corrections:
          I: turn debugger off
          II: add a cin.ignore(5,'\ n'); followed by a getline(cin, yourVAR); right before the return in main ( or } if you are using void main(void){})

          Peace
          V

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Originally posted by vninja
            corrections:
            I: turn debugger off
            II: add a cin.ignore(5,'\ n'); followed by a getline(cin, yourVAR); right before the return in main ( or } if you are using void main(void){})
            Put a break point on the last line of code.

            You get this from Visual Studio too, run in the debugger and the program just exits, but run normally and the CMD prompt waits after the program has terminated to be shut by the user.

            Therefore I only use the debugger when I actually have break points set that I want to hit. Otherwise I just run the program normally.

            Comment

            Working...