1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| #include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
int main()
{
struct dirent *file;
DIR *rep;
FILE *fp;
rep = opendir("C:\fichiers");
if (rep != NULL) {
while ((file = readdir(rep))) {
printf("%sn", file->d_name);
fp = fopen(file->d_name, "rb");
if (fp == NULL)
{
puts("n> Impossible d'ouvrir le fichier : ERREUR");
puts("> Appuyez sur une touche pour continuer...");
} else {
fscanf(fp, "%s", file->d_name);
puts("executable");
}
fclose(fp);
}
}
closedir(rep);
getch();
return 0;
} |
Partager