ABSTRACT

A file refers to a disk file that stores some information in textual form and is sometimes referred to as a data file. We can create a data file, write some information in it, store it in an appropriate place, and in the future can access it to read/write or update the information present in it. The C language provides us with various predefined functions to perform these operations on a file. The process of file handling follows a simple flow of operations, starting with opening a file using the fopen() function, performing the required operations (read/write), and finally closing the file with the fclose() function. A file can contain various data, such as integers, characters, and strings. We can use predefined functions, like fprintf(), fscanf(), fputc(), fgetc(), fputs(), fgets(), putw(), and getw(), to read/write these data from/to a file. The description of all these functions, along with their syntaxes, is explained in this chapter.