0

该程序使用了rewind() 函数,为什么在下面的情况下,rewind() 函数使必须刷新缓冲区的条件为真?

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char * argv[])
{

       FILE * file_output = fopen("output.txt", "w+");
       char ch;

       printf("Insert a character: ");
       scanf("%c", &ch);
       while (getchar() != '\n');

       putc(ch, file_output);
       rewind(file_output); // <-- TEST THIS CODE WITH AND WITHOUT REWIND()

       printf("Read character: ");
       printf("%c\n", getc(file_output));

       fclose(file_output);

       return 0;
}
4

0 回答 0