Is it necessary that a file created in text mode must always be opened in text mode for subsequent operations?

,

thanks a lot.

On a UNIX system, when an application reads from a file it gets exactly what’s in the file on disk and the converse is true for writing. The situation is different in the DOS/Windows world where a file can be opened in one of two modes, binary or text. In the binary mode the system behaves exactly as in UNIX. However on writing in text mode, a NL (\n, ^J) is transformed into the sequence CR (\r, ^M) NL.

This can wreak havoc with the seek/fseek calls since the number of bytes actually in the file may differ from that seen by the application.