I have a txt file with unix files listed in it. I need to get the file names in that file, and open those files for some processing.
I can open the txt file ok, but when I use the "obtained" string in a subsequent fopen call, it fails with error code 2 (NOENT).
snippet:
[
FILE *F;
char filename[256];
f = fopen("list.txt", "r"
if(f != NULL)
{
fgets(filename, 256, f);
printf("%s", filename); -- prints: /tmp/my_c_file.c
fclose(f);
}
else
return -1;
f = fopen(filename, "rb+" -- fails
]
Any hints?
Thanks in advance.
I can open the txt file ok, but when I use the "obtained" string in a subsequent fopen call, it fails with error code 2 (NOENT).
snippet:
[
FILE *F;
char filename[256];
f = fopen("list.txt", "r"
if(f != NULL)
{
fgets(filename, 256, f);
printf("%s", filename); -- prints: /tmp/my_c_file.c
fclose(f);
}
else
return -1;
f = fopen(filename, "rb+" -- fails
]
Any hints?
Thanks in advance.