C
collinm
i try to search txt file in a folder
my code
i call this function with
all my file name are the same size...
they are surely a better way to do it (the file name size are not the
same)...
i would like to put the file name in a list....
what is the better way to do it?
my code
Code:
int searchfile(char *dir, char *filename, int flength, char *ext)
{
DIR *pdir;
pdir = opendir(dir);
struct dirent *pent;
if (!pdir)
{
printf ("%s - Incapable d'utiliser opendir()\n", strerror
(errno));
return 1;
}
while((pent = readdir(pdir)) != NULL)
{
if(strcmp(pent->d_name + flength, ext) == 0)
{
printf("%s\n", pent->d_name);
}
}
closedir(pdir);
return 0;
}
i call this function with
Code:
searchfile(local_dir_led,"", 28, ".txt");
all my file name are the same size...
they are surely a better way to do it (the file name size are not the
same)...
i would like to put the file name in a list....
what is the better way to do it?