C Program to Print names of all Files present in a Directory
dirent.h header file contains variables and functions related to directory streams.
Below is a program to print the names of all the files in a directory.
struct dirent *dir;
d = opendir(".");
while ((dir = readdir(d)) != NULL)
We can also take the directory name as input from the user, and can also create a simple C program to search for a particular file in a directory.