6
I’m creating a variable:
char nome[20];
After this, I am 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 I need to do this, using the function toupper()
in case the user type the lowercase name, make it uppercase, therefore working the if
.
Attempt at the if
with toupper
:
if(strcmp(toupper(nome,"maria")== 0)){
printf("\nCor favorita : Vermelho");
printf("\nFruta favorita : Morango");
}
Mistakes :
invalid Conversion from 'char*' to 'int' [-fpermissive]
Too Many Arguments to Function 'int toupper(int)'
cannot 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 the if
? Or inside it ?
Put the code that you tried so we can see where the error is. And tell us what the errors are.
– Maniero