From the file encoding methodFiles can be divided into ASCII files andBinaryTwo types of code files.
An ASCII file is also called a text file. When a file is stored on a disk, each character corresponds to one byte and is used to store the corresponding ASCII code. For example, the storage format of hundreds of thousands is:
ASC: 00110101 00110110 00110111 00111000
↓
Decimal code: 5 6 7 8 occupies 4 bytes in total. ASCII code files can be displayed by characters on the screen, such as the sourceProgramThe file is an ASCII file. You can use the doscommand type to display the file content. Because it is displayed by characters, you can read the file content.
BinaryThe file isBinaryEncoding method to store files. For example, the storage format of hundreds of thousands is: 5678 00010110 occupies only two bytes.BinaryAlthough the file can be displayed on the screen,
However, the content cannot be understood. When processing these files, the C system treats them as byte streams and does not differentiate the types. The start and end of the input and output streams are only controlled by the program, not by physical symbols (such as carriage returns. Therefore, this type of file is also called a "streaming File ".
an object can be opened in text mode or binary mode, in text mode, carriage return is treated as a character '\ n', while binary mode considers it to be two characters: 0x0d and 0x0a. If you read 0x1b in the file, the text mode considers it to be the end of the file, that is, the binary model does not process files, the text method converts the data in a certain way.