M
Markus Pitha
Hello,
i'm using Gentoo Linux and like to open directories which i got from a
text file i read of. I tried to open a directory as i wrote the
directory name directly into "opendir()" and it worked. When i use this
pointer on the array "input", which contains the actual directory, the
program cannot read the directory.
I already tested if "input" contains the directories at all, but it does.
Any ideas?
i'm using Gentoo Linux and like to open directories which i got from a
text file i read of. I tried to open a directory as i wrote the
directory name directly into "opendir()" and it worked. When i use this
pointer on the array "input", which contains the actual directory, the
program cannot read the directory.
I already tested if "input" contains the directories at all, but it does.
if ((fp = fopen(fpath, "r")) == NULL) {
fprintf(stderr, "Couldn't open config file");
exit(1);
}
while (!feof (fp) ) {
fgets(input, pathlength, fp);
if ((dir=opendir(input)) != NULL) { /* opendir cannot open the directory, stored in "input" */
while ((dirzeiger=readdir(dir)) != NULL)
printf("%s\n", (*dirzeiger).d_name);
}
closedir(dir);
}
fclose(fp);
Any ideas?