10

Files

Learning Objectives

In this chapter, you will learn about:

  • Files

  • C’s approach to perform file input-output

  • Streams

  • How to create, read, write and update files

  • Sequential access files

  • Random access files

10.1 Introduction

In the previous chapters, we have used functions such as scanf and printf to read and write data. These are console input-output (I/O) functions that read data from or write data to the terminal, i.e. keyboard and screen, respectively. The console I/O is preferred in interactive programs where the amount of data in I/O is small. If a program deals with I/O of large volume of data, the console I/O is not convenient and consumes a lot of time. Moreover, the entered data are stored in variables and arrays. These ...

Get Programming in C: A Practical Approach, First 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.