How to display the "Press any key to continue" in C ++?

2

In C, I put the "Press any key to continue" with the getchar () command. in C ++, how do I do it?

    
asked by anonymous 09.05.2015 / 21:58

2 answers

5

You can use the getchar() function.

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    cout << "Pressione qualquer tecla para continuar..." << endl;
    getchar();
    return 0;
}
    
09.05.2015 / 22:08
0

To display the "Press any key to continue", you must include the <cstdlib> library and add system("pause") to the desired location.

Note, however, that this function does not return the key pressed, only pauses execution and resumes it after pressing.

    
10.05.2015 / 02:56