ABSTRACT

Real-world programs often need to perform access operations on files. This chapter introduces C's most important library functions dealing with files. A text file consists of one or more lines that contain readable characters according to a standard format, like the American Standard Code for Information Interchange (ASCII) code. Each line ends with the special character(s) that the operating system uses to indicate the end of line. Binary files might seem a better choice, but they have some disadvantages. When a binary file is transferred from one system to another, the data might not be represented the same, because different systems might store them in different ways. In C, the term stream refers to a source of data or a destination for output. The most common functions to write data in a text file are: fputs(), fprintf(), and fputc().