I'm creating a variable:
char nome[20];
After this, I'm asking the user to enter a name:
printf("Digite um nome : ");
scanf("%20s",&nome);
And I'm checking to see if the name is correct:
if(strcmp(nome,"Maria") == 0){
printf("\nCor favorita : Vermelho");
printf("\nFruta favorita : Morango");
}
The problem is that I need to do this, using the toupper()
function in case the user type the lowercase name, it causes it to be uppercase, so running if
.
Attempting if
with toupper
:
if(strcmp(toupper(nome,"maria")== 0)){
printf("\nCor favorita : Vermelho");
printf("\nFruta favorita : Morango");
}
Errors:
invalid conversion from 'char *' to 'int' [-fpermissive]
too many arguments to function 'int toupper (int)'
can not convert 'bool' to 'const char *' for argument '1' to 'int strcmp (const char *, const char *)'
I would have to convert the variable with the function toupper()
before if
? Or inside it?