I am trying to open a directory, and then open a file named "YouTubeSign", directory opens fine, but for some reason fopen() on the file fails even if the file exists; any ideas?
int main(int argc, char **argv)
{
DIR *pdir = NULL;
struct dirent *in_file;
FILE *signature = NULL;
pdir = opendir(argv[1]);
if (pdir == NULL)
{
printf("could not open directory %s", argv[1]);
return -1;
}
while (in_file = readdir(pdir))
{
if (strcmp(in_file->d_name, "YouTubeSign") == 0)
{
signature = fopen(in_file->d_name, "r");
printf("opening youtubesign");
break;
}
}
if (signature == NULL){
printf("could not open file ");
return -1;
}