Hi, I'm trying to pass filenames to a function that opens the files and reads the data in. At this stage my file pointers are just returning NULL and I can't work out what I'm doing wrong. Any tips would be very much appreciated!
Thanks in advance...
Code:
int loadData(GJCType* menu, char* menuFile, char* submenuFile)
{
FILE *fp1 = NULL, *fp2 = NULL;
printf("menuFile filename is is %s\n", menuFile);
printf("submenuFile filename is %s\n", submenuFile);
printf("Attempt to load data!\n");
fp1 = fopen(menuFile, "r");
fp2 = fopen(submenuFile, "r");
if (fp1 == NULL)
{
fprintf(stderr, "Menu File open error\n");
}
else {
printf("Menu File open success, I think!\n");
}
if (fp2 != NULL)
{
printf("Sub Menu File open success, I think!\n");
}
else {
fprintf(stderr, "Sub Menu File open error\n");
return EXIT_FAILURE;
}
return 1;
}