'Micro manipulation' of scanf function
Read the question carefully, the title describes "multiple input", we can use the while loop to achieve!
Through reference, the ASCII code value +32 of uppercase letters is the corresponding lowercase letter.
Look at the code:
However, when testing next, the value is not what we expected.
Here is an extra *, so I went to carefully check the usage of scanf, and we typed'A' and hit Enter, the buffer really appeared'A\n', and the scanf function recorded'A' this time Yes, the next time you record'\n', and the ASCII code value of'\n' +32 is *!
At this point, the problem is found, but how to solve it.
When we enter the loop, we can use getchar() to enter.
Look at the effect:
Same type of questions
This is to determine whether the input is a letter. After having the foundation just now, go directly to the original code and add additional if judgments.
Of course, there is another comparison method.
study well!
You must remember the usage of some basic functions, including the return type and variable type. You can't just know the general idea!