Chapter 22

Permanent Storage Functions

IN THIS CHAPTER

check Working with file functions

check Reading and writing text to a file

check Creating binary files

check Using the fread() and fwrite() functions

check Reading and writing records

check Building a linked-list database

C programs work innately with storage in memory. Variables are created, values are set, locations are mapped. It’s all pretty much automatic, but the information that’s created is lost after the program runs.

For the long term, programs need to access permanent storage, writing and reading information to and from files. C comes with a host of interactive functions that let you create, read, write, and manipulate files. These are the permanent storage functions.

Sequential File Access

The simplest way that information can be written to or read from a file is sequentially, one byte after the other. The file contains one long stream of data. This ...

Get C Programming For Dummies, 2nd Edition 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.