After compiling and running a c++ program ...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TAboy24
    New Member
    • Nov 2007
    • 5

    #1

    After compiling and running a c++ program ...

    how can i stay at the "black dos window" without exiting from it write away...

    a)if it exit ,how can i review it by clicking a button or some F or something to see what it actualy has done?
    b)how can i prevent that from hapening by adding a proper code to my program?
    thank you very much!
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    Well, if you're using Visual Studio, you can hit "Run without debugging" or "start debugging", whichever one you aren't using now...it's been a while since I used VS...One of those two flashes the screen, the other lets you actually look at it.

    Comment

    • looker
      New Member
      • Dec 2007
      • 18

      #3
      Originally posted by TAboy24
      how can i stay at the "black dos window" without exiting from it write away...

      a)if it exit ,how can i review it by clicking a button or some F or something to see what it actualy has done?
      b)how can i prevent that from hapening by adding a proper code to my program?
      thank you very much!
      Well, in fact there are a few technic to do that
      - If you are using an IDE such as Visual Studio, you can set break point on where you want to pause the execution ( press F9 ). then you just click start debugging.

      - If you are using a command based compiler such as Mingw, you can call getchar() in stdio.h in order to pause the execution.
      This is the example
      [code=cpp]
      #include <stdio.h>
      int main()
      {
      printf("hello world");
      getchar();
      return (1);
      }[/code]
      Last edited by sicarie; Dec 5 '07, 04:52 AM. Reason: Code tags

      Comment

      Working...