C program to list files of a directory

  • برمجة سي c

C program to list files of a directory

 

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

الأجوبة

#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); // The first '*' is for all file names and the second one is for all file extensions

   while(!done)
   {
      printf("%s\n", a.ff_name);
      done = findnext(&a);
   }

   getch();
   return 0;
}
هل كان المحتوى مفيد؟

القوائم الدراسية التي ينتمي لها السؤال

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...