Alternative to C library-function fflush(stdin)

后端 未结 2 958
半阙折子戏
半阙折子戏 2021-01-26 09:32

Can anyone explain how the following code could be explained, I dont understand it really.

while((c = getchar()) != \'\\n\' && c != EOF);
2条回答
  •  梦毁少年i
    2021-01-26 10:19

    This code, assuming the file (or some other input) has been opened, will continue to get character by character until it finds a newline (\n) or an end of file (eof).

    fflush will just clear the stream for an open file.

提交回复
热议问题