2
In C, I put "Press any key to continue" with the getchar(). command in C++, as I do?
2
In C, I put "Press any key to continue" with the getchar(). command in C++, as I do?
5
You can use the function getchar()
even.
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
cout << "Pressione qualquer tecla para continuar..." << endl;
getchar();
return 0;
}
0
To display the "Press any key to continue", you must include the library <cstdlib>
and add system("pause")
at the desired location.
Note, however, that this function does not return the pressed key, only pause the execution and resume after pressing.
I’m in a Linux environment. The system("pause") won’t work here. But I did. I included the <stdio library. h>, same as C, in C++, kept my <iostream> and put getchar();
I wanted to take out this message from "Press any key to continue" and even then the program take the break, have as?
Browser other questions tagged c++
You are not signed in. Login or sign up in order to post.
It doesn’t work because if some gringo goes to use the code, he won’t know what it says.
– CypherPotato
@Cypherpotato As far as I understand the author asked only how to display the text "Press any key to continue...". In my view the example answers exactly what was asked. Agree? + 1 to answer.
– Guilherme Nascimento
Yes, at a certain point it’s right. But if he’s going to have to distribute, he’ll have to use the guy’s method below.
– CypherPotato
@Cypherpotato I didn’t understand, distribute exactly what and for what? If you have any suggestions for better use please post an answer, I guarantee that a vote will already have (depending on the answer), my (:
– Guilherme Nascimento
@Cypherpotato Works, works =) AP did not explain this fact you said, but if you need to display the text in another language, you can use the
cin.get()
. Or if you need something more elaborate, use the functionGetSystemDefaultUILanguage
to detect the language of S.O and display the text in that language. Aboutsystem("pause")
, is something just Windows, take a look too in this matter of the OS.– stderr
Yeah, but he wouldn’t have to wear one
Switch
for each language of the system, would pick something more dynamic, correct?– CypherPotato
@Cypherpotato If using the function
GetSystemDefaultUILanguage
orGetUserDefaultUILanguage
, she will return a language identifier, that identifier you compare with a specific language, for example French, and print the text in this language. =)– stderr
@Cypherpotato I really just wanted to use this. I won’t have to distribute at the moment.
– Mateus Souza
I don’t use C++, sorry...
– CypherPotato
Nothing to be sorry about, @Cypherpotato =)
– stderr
Thank you haha :D
– CypherPotato