Jump to content

Recommended Posts

Posted

É possível utilizar o case com strings por exemplo:

switch(variavel)
{
case  "portugal":

break;
}

Resolvi o assunto assim

if(strcmp(pal,pal1) == 0) {

}

Mas gostaria de saber se é possivel e como fazer o case funcionar com strings porque o código ficava mais bem organizado

Posted

Acho que é possível, basta fazeres assim

switch(variavel)
{
case  'portugal':

break;
} 

Lema: Se eu não saber de alguma coisa não se preocupem porque tento sempre ajudar alguma coisita, nem que seja, por palpites/sugestões.

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
×
×
  • 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.