In C, I put the "Press any key to continue" with the getchar () command. in C ++, how do I do it?
In C, I put the "Press any key to continue" with the getchar () command. in C ++, how do I do it?
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;
}
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.