c - how gets() work after scanf? [duplicate]
问题 This question already has answers here : scanf() leaves the new line char in the buffer (4 answers) Closed 3 years ago . I have two questions: why only when i do space in "%d " --> scanf("%d ", &num); it works? I tried fflush(stdin) \ _flushall() between the scnaf and the gets and it doesn't works, it skips the gets. When I do the space, it first does scanf then the gets and after that it print the number and print the string. void main() { char ch, str[10]; int num; printf("Enter your number