3

Possible Duplicate:
How to stop C++ console application from exiting immediately?

I'm working with c++ and when I run my console program, it instantly exits. I can't read input from in my main method/set breakpoints because the main method is defined in another library.

So, I'm asking how can I prevent the console application from exiting by using a setting in visual studio?

Community
  • 1
  • 1
NomenNescio
  • 2,899
  • 8
  • 44
  • 82

2 Answers2

5

Try running with Ctrl+F5. This will stop the console at the end of the execution.

Archie
  • 6,391
  • 4
  • 36
  • 44
3

If I understood correctly you can't read the output of your program because console closes immediately. To prevent this you can call system("pause"); just before returning from main.

int main()
{
    // processing...
    system("pause");
    return 0;
}
nogard
  • 9,432
  • 6
  • 33
  • 53