Jump to content

Escolha de menus... a ou A?


jcorreia
 Share

Recommended Posts

Boas pessoal,

Cá continuo eu com o meu trabalho e a precisar da vossa ajuda novamente...

Tenho vários menus e vão ser escolhidos com o tecla pressada, por exemplo:

A->Mando o Pinto da Costa pra jaula

B ->Mando o Valentim para a prisão

😉

lol, mas a questão seria é a seguinte eu quero que o programa aceite o a/A ou b/B

o programa está feito com "case"...

Obrigado

Link to comment
Share on other sites

Realmente... sou mesmo básico!! 😉

Obrigadão

//This uses lowercase an uppercase characters

cout << "\n\nType in lowercase or uppercase a or b: ";

cin >> ch;

switch(ch)

{

case 'a': case 'A':

cout << "You typed in an A!\n";

break;

case 'b': case 'B':

cout << "You typed in an B!\n";

break;

default:

cout << "You didn't type in a or b!\n";

break;

}

getchar(); // wait for a key to be pressed.

return 0;

}

Assim já funciona...

Obrigado na mesma

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.