Using Visual Studio and C ++ how do I prevent the debug screen from closing automatically?

2

Using the code below I type the two numbers, but if I give enter after entering the second number the answer appears quickly and the debug closes.

int main(){

int num1, num2, answer;

cout << "Digite um número:";
cin >> num1;

cout << "Digite um número:";
cin >> num2;

answer = num1 * num2;
cout << "Resultado:" << answer << endl;

cin.get();
return 0;
}

I put

cin.get();

But it did not work.

I'm trying to use Ctrl + F5 to debug, but clicking on F5 locks my cursor and I have to click again to unlock, why?

    
asked by anonymous 03.10.2014 / 08:29

3 answers

3

You should insert a breakpoint into the code, so the debugger will stop and you can view the information of the execution context.

Use the shortcut keys to perform step-by-step code. If your IDE is set to the Visual Studi 6 (Tools-> Environment-> Keyborad) shortcut pattern for C ++ projects, use:
F5 - runs to the stopping point, if any;
F9 - inserts stop point / removes break point at the position where the course is, or nearest position valid;
F10 - performs step-by-step

F11 - enters the routine.

    
03.10.2014 / 13:53
1

After doing a search, I checked that I can prevent the debug screen from closing using:

 system("PAUSE");
    
03.10.2014 / 08:38
0

use

system("pause");

But to use this tool you have to add an extra library to

#include <stdlib.h>
    
18.06.2018 / 03:58