Content deleted Content added
mNo edit summary |
No edit summary |
||
Line 31:
The 'b' stands for binary. The C standard gives two kinds of files - text files and binary files - although operating systems may or may not distinguish between the two. A ''text file'' is a file consisting of text arranged in lines with some sort of distinguishing end-of-line character or sequence (in [[Unix]], a bare linefeed character; in the [[Apple Macintosh|Macintosh]] OS, a bare carriage return; on [[DOS]] and [[Microsoft Windows]], a carriage return followed by a linefeed). When bytes are read in from a text file, an end-of-line sequence is usually mapped to a linefeed for ease in processing. When a text file is written to, a bare linefeed is mapped to the OS-specific end-of-line character sequence before writing. A ''binary file'' is a file where bytes are read in "raw," and delivered "raw," without any kind of mapping.
When a file is opened with update mode ( '+' as the second or third character in the mode argument), both input and output may be performed on the associated stream. However, writes cannot be followed by reads without an intervening call to fflush() or to a file positioning function ( [[Fseek | fseek()]], fsetpos(), or [[Rewind (C) | rewind()]]), and reads cannot be followed by writes without an intervening call to a file positioning function. [http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html]
Writing and appending modes will create a file to write to in the case that the file name doesn't already exist. However, the operation of fopen is undefined if the filename doesn't follow requirements by the OS. For example, if the filename contains illegal characters , the program might crash. For example, in windows \ /: * ? < > and | cannot be part of a file name.
|