Files are used to store data permanently on hard disk. C programming supports built in library function to interact with files and directories. I have compiled a list of file handling exercises with solution for beginners and intermediate programmers.
File handling
C program to list all files in a directory recursively
Quick links
Write a C program to list all files in a directory. How to list all files in a directory recursively. How to use readdir()
function to list all files in a directory recursively. Logic to list all files and sub-directories of a directory in C programming. How to use opendir()
, readdir()
and closedir()
library functions.
C program to rename a file using rename() function
Quick links
Write a C program to rename a file using rename()
function. How to rename a file using rename()
function in C programming. rename()
function in C programming.
C program to check whether a file or directory exists or not
Write a C program to check whether a file or directory exists or not. How to check file or directory exists or not in C programming. What is the best way to check file or directory exists or not in C programming.
C program to find file properties using stat() function
Quick links
Write a C program to check file properties using stat()
function. How to check file permissions, size, creation and modification date of a file in C programming. How to use stat()
function to find various file properties.
C program to print source code of itself as output
Quick links
Write a C program to print source code of itself as output. How to print source code of itself as output in C programming.