Click on any exercise below to see the source code, program output and explanation of the code.  The exercises in this section deals with file processing. In C, a program can open, read, write and close named files by using standard functions such as fopen(), fscanf(), fprintf() and fclose(). C defines a pointer data type FILE* to ease the manipulation of files.

Available Exercises

Exercise 6.1. Write a program to determine that two binary files are identical. If they are different, prints the first byte at which they differ.

Exercise 6.2. Write a program to copy the content of one file into another.

Exercise 6.3. Write a program to read a binary file of integers, sort the integers and write them back into the same file.

Exercise 6.4. What is the difference between a file opened with “r+” and one opened with “w+”?

Exercise 6.5. Write a program to read a text file and produce some statistical analysis of the file.

Exercise 6.6. Write a program to encrypt a text file using the Caesar shift cipher.

Exercise 6.7. Write a program to decrypt a text file encrypted as in Exercise 6.6