0

The second scanf() function is not taking any input. How can I take another input? And why is this happening?

#include<stdio.h>

int main()
{
    char u, v;
    printf("Enter lowercase character :");
    scanf("%c",&u);
    printf("Uppercase is : %c\n",u-32);
    printf("Enter uppercase character :");
    scanf("%c",&v);
    printf("Lowercase is : %c\n", v+32);

}
Darth-CodeX
  • 2,166
  • 1
  • 6
  • 23
  • The second `scanf` is taking input. It is taking the second character as input, which is the newline character that was generated by pressing the ENTER key on the first line. See the duplicate question for further information and on how to fix this. Personally, I think it is best to use the function [`fgets`](https://en.cppreference.com/w/c/io/fgets) to always read a whole line of input as a string, instead of using `scanf` to read partial lines. – Andreas Wenzel Jun 03 '22 at 17:37
  • 1
    You may want to read this: [A beginners' guide away from scanf()](http://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html) – Andreas Wenzel Jun 03 '22 at 17:46
  • This question could also be useful: [What can I use for input conversion instead of scanf?](https://stackoverflow.com/q/58403537/12149471) – Andreas Wenzel Jun 09 '22 at 12:52

0 Answers0