Monday, 2 December 2013

C program to list files in directory

C programming code(Turbo C compiler only)

#include <stdio.h>
#include <conio.h>
#include <dir.h>
 
int 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;
}
Obviously you will get a different output when you will execute this file on your computer.

No comments:

Post a Comment