Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
fseek
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Alan Balmer, post: 1687346"] This paragraph only describes the mode that the stream is opened in, saying nothing about the files themselves. It does not say that opening a file in the "wrong" mode results in undefined behavior. The mode is important to the user, since in text mode it tells the I/O implementation that it must look for, and possibly map, newline characters. In binary mode, newline characters are treated the same as any other character. Opening a text file in binary mode is perfectly legitimate - in fact the standard provides no way to distinguish between a binary file and a text file. Refer to 17.19.2, where the two types of streams are defined. Now, consider a "text" file containing one "line." The thing that makes it a text file is that each "line" has a terminating newline character. But the standard says that the last line need not have the terminating newline (it's implementation dependent.) How can this file be distinguished from a binary file? What will the implementation do to me if I open it in binary mode? On the other hand, presume that I have a binary file, say an executable program. This file may contain numerous instances of a character with the value 0xA, which happens to be the newline character on the system I'm using now. Does that make it a text file? Obviously not, but it may meet all the criteria for opening as a text stream. Perhaps Dan is right, and the writers made a mistake. I'm in no position to make a judgment on that. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
fseek
Top