Hi,
I'm pretty new to C and I currently have this problem where I want a function to return a file pointer because I have this expression through out my program several time, so I wanted to use a function to minimize the lines of code. Currently I have:
insert
Code:
FILE Exam(void)
{
FILE *fr;
fr = fopen("Exam.txt", "r");
if (fr == NULL)
{
printf("The file didn't open.\n");
return 0;
}
return fr;
}
but it gives me the following errors:
error C2440: 'return' : cannot convert from 'int' to 'FILE'
error C2440: 'return' : cannot convert from 'FILE *' to 'FILE'
if you could help it would be greatly appreciated. Thanks.