Fflush is used to clear the buffer stream. Although it is generally invisible, the default printf is used to buffer the output. Fflush (stdout), so that stdout is cleared, it will immediately output all content in the buffer. The fflush (stdout) example may not be obvious, but it is obvious to stdin. The following statement: int A, C; scanf ("% d", & A); C = getchar (); input: 12 (Press ENTER) then a = 12, C = '\ n' and: int A, C; scanf ("% d", & A); fflush (stdin); C = getchar (); input: 12 (Press ENTER) So A = 12, C does not get the input value for the moment, you need to enter C again, because getchar is also a buffer input, '\ n' is still in the buffer, but it is cleared. In addition, fflush cannot be used to redirect input streams. Fflush (stdin) refreshes the standard input buffer and discards the content in the input buffer.
Fflush (stdout) refreshes the standard output buffer and prints the output buffer to the standard output device.
Fflush (stdout); // What is the role of this sentence ??? --What is the role of fflush ()?: If a pointer is written to an opened file in parentheses, the content of the output buffer is written to the file pointed to by the pointer. Otherwise, the output buffer is cleared. Stdout is the standard output file pointer defined by the system. By default, it refers to the screen, that is, the buffer content is written to the screen. HoweverCodeI can't see what the buffer will do, so it does not actually do anything.