Can fseek(stdin,1,SEEK_SET) or rewind(stdin) be used to flush the input buffer instead of non-portable fflush(stdin)?
问题 Since I discovered fflush(stdin) is not a portable way to deal with the familiar problem of "newline lurking in the input buffer" ,I have been using the following when I have to use scanf : while((c = getchar()) != '\n' && c != EOF); But today I stumbled across this line which I had noted from cplusplus.com on fflush: fflush()...in files open for update (i.e., open for both reading and writting), the stream shall be flushed after an output operation before performing an input operation. This