Enter lower case/upper case in C

Asked

Viewed 115 times

-1

How do I independent of the user typing the letter in lower or upper case read by scanf_s?

printf("\nVocê gostou do nosso produto?\n" 
            "\n[S] - Sim"
            "\n[N] - Não\n\n"
            "RESPOSTA:\t\n");
scanf_s(" %c", &p);
  • You want the entire input to be formatted to minuscule or uppercase ?

  • 2

    Every "letter" is read by scanf, either uppercase or lowercase. If you’re having trouble, it’s definitely not in the code you posted. It would be important to [Dit] and provide a [mcve] of the problem. Most likely your question is a XY problem.

1 answer

0

Use the function toupper of <ctype.h>. After your scanf do:

p = toupper(p);

that p will be capitalized regardless of whether it has been typed in upper or lower case.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.