Hello,
I'm trying to open file using a function in a header file and I think it works but I'm unsure if it's written as it should be. Should I use double pointer inside the FileOpen function like argv is or not? It also works without double pointers and that's why I'm asking this.
int main(int argc, char **argv)
{
FILE *data, *result;
FileOpen (&data, argv[1], "r");
FileOpen (&result, argv[2], "w");
fclose(data);
fclose(result);
return 0;
}
int FileOpen (FILE **file, char *filename, char *mode) {
*file = fopen (filename, mode);
if (*file == NULL) {
fprintf(stderr, "File not found: %s\n", filename);
return FALSE;
}
return TRUE;
}