Chapter 15

Files

Real-world programs often need to perform access operations on files. This chapter introduces C’s most important library functions designed specifically for use with files. We won’t describe them in full detail, but we’ll give you the material needed in order to perform file operations. In particular, you’ll learn how to open and close a file, as well as how to read and write data in text and binary files.

Files in C

C supports access operations on two kinds of files: text and binary.

A text file consists of one or more lines that contain readable characters according to a standard format, like the ASCII code. Each line ends with special character(s) the operating system uses to indicate the end of line.

In Windows

Get C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.