Popular Posts

Tuesday, 28 February 2012

c program to list files in directory

This program list all files present in a directory/folder in which this executable file is present. For example if this executable file is present in C:\\TC\\BIN then it will lists all the files present in C:\\TC\\BIN.

C programming code

#include<stdio.h>
#include<conio.h>
#include<dir.h>
 
main()
{
   int done;
   struct ffblk a;
 
   printf("Press any key to view the files in the current directory\n");
 
   getch();
 
   done = findfirst("*.*",&a,0);
 
   while(!done)
   {
      printf("%s\n",a.ff_name);
      done = findnext(&a);
   }
 
   getch();
   return 0;
}

Download list files program executable.
Output c program to list files is shown in image below :-

list files

No comments:

Post a Comment