I do know how to read all the files from the current directory by opening directory "./" and then using readdir. But, how do I list only .txt files or any other specific extension?
DIR *p;
struct dirent *pp;
p = opendir ("./");
if (p != NULL)
{
while ((pp = readdir (p))!=NULL)
puts (pp->d_name);
(void) closedir (pp);
}