need of fseek() in c

后端 未结 1 557
温柔的废话
温柔的废话 2021-01-15 19:51

Part of Code 1:-

while(1)
    {
        ch=fgetc(pt);
        if(c==EOF)
        {
            break;
        }
        if(c==\' \')
        {
            f         


        
1条回答
  •  粉色の甜心
    2021-01-15 20:15

    The use of fseek() here - The C standard requires a positioning operation between a read and a write operation on an update stream, or between a write and a read. This is a positioning operation between a write and a read. It is not a no-op; it places the stream into a mode which allows the next fgetc() to work correctly, reliably, across platforms, as required by the C standard.

    EDIT:

    2 fseek() calls are required because the first one acts as the "no-op" call between an fgetc() and a subsequent fputc() call. After the fputc(), the second one acts as the "no-op" between the fputc() and the subsequent fgetc() call. (since a loop is running)

    0 讨论(0)
提交回复
热议问题