1
while(1)
{
    ch=fgetc(ft);
    if(ch==EOF)
    {
        break;
    }
    if(ch=='u')
    {
        fputc('b',ft);
        fflush(ft);
    }
}

I tried to replace character after u with b in a file pointed by *ft.

This code runs fine but when I open the file it seemed to be unedited.

The above code works fine with fseeks(ft,0,SEEK_CUR).

Why it is not working with fflush(ft).

4

1 回答 1

1

fflush 仅刷新输出流。因此,您需要fseek(ft,0,SEEK_CUR)fputs(ft)

于 2014-02-23T12:55:01.087 回答