Suspend after debugging command line application in Visual Studio

Is there a way to write a separate batch file or add a system call to pause or getch or a breakpoint before the end of the main function to keep the command window open after the command line application has finished running?

Differently, is there a way in the project properties to run another command after the target path has started? If my program is "foo.exe" then it is equivalent to a batch file containing

@foo
@pause

      

Edit: added "or getch or breakpoint"

+1


source to share


4 answers


As you probably know, at least in the C # project system, pressing Ctrl-F5 will add "until the end of any key to continue". But this doesn't work under the debugger, so I endorse the previous answer, which says "put a breakpoint at the end of the main one."



+5


source


If you're working in the debugger (following the title of your question), I'll just put a breakpoint in the closing parenthesis in the main method.



+3


source


In C ++

#include <conio.h>

// .. Your code

int main()
{
  // More of your code

  // Tell the user to press a key 
  getch();      // Get one character from the user (i.e a keypress)

  return 0;

}

      

If you are in a batch file, the "pause" command displays "Press any key to continue" and waits for a key press.

0


source


If you have access to the source code,

1.) Will the add getch () be added just before the main ends and not puase to execute the application while the console application console window is displayed? Basically add any code that waits for keyboard input

-AD

0


source







All Articles