Skip to content

Chapter 20: File IO

20.1 Introduction

20.2 Streams

20.3 Standard streams

20.4 Pointers to streams

20.5 Opening and closing Files

Opening Files

Closing files

20.6 Stream buffering functions

The fflush function

The setbuf function

The setvbuf function

20.7 Functions that modify the file position indicator

The fgetpos and fsetpos functions

The fseek and ftell functions

The rewind function

20.8 Error handling functions

The clearerr function

The feof function

The ferror function

The perror function

20.9 Other operations on files

The remove function

The rename function

The tmpfile function

The tmpnam function

20.10 Reading from files

Character input functions

EOF pitfall

Direct input function: the fread function

Formatted input functions: the scanf family of functions

20.11 Writing to files

Character output functions

Direct output function: the fwrite function

Formatted output functions: the printf family of functions

20.12 References