This program is to stay in a hotel, input the correct number of days, only captures the input number function part, There are two don't understand. (1) the conditions in the while loop, I understood as when days are 1, not into the circulation, enter not into the loop when 1 (but is not in conformity with the simply enter again the purpose of the correct number of days), Can run, no matter what I input Numbers (including 1) will not enter the circulation, (that is, the application meets the requirements) That is, the program is right, is to meet the requirements, but I understand is wrong, for the
2 cycles of the scanf (' * '% s') What is the role of (1) * (2) why do you want to join this statement here? (after I get rid of this statement, the program may enter the infinite loop, I can't understand why)
CodePudding user response:
The scanf data obtained from the return value is the correct item number, Circulation inside the scanf is to remove the input buffer, With a * is one of the input is said that the, but after input to throw away, don't send to variables, so no follow behind accept input address,