I have previously posted a question about using code to access a file when the actual name of the file is unknown. the entire name of the text file is stored in a structure component at
file_info[selection].name. I am confused how I should go about opening this file
that portion of my code looks like this thus far.
Code:
FILE *readfile;
char temp;
temp = file_info[selection].name;
readfile = fopen(temp,"r");
if(readfile == NULL)
{
printf("\nfile could not be opened");
}
else
{
printf("\n file was opened");
}
fclose(readfile);
return 0;
Can anyone figure out why this won't work? I appreciate your help.