My program is supposed to ask a user to enter a text file that isin this format:
ID: 3619184 • Letter: M
Question
My program is supposed to ask a user to enter a text file that isin this format:MATH
101
GEOLOGY
101
GYM
101
I'm supposed to read each of the subject name and store it in anarray and store the subject numbers in another array.
I'm not sure how to do it, I know I have to use fscanf but i'mreally stuck!
Here is what I have so far:
int main()
{
FILE* pFile = NULL;
char data[100];
char filename[80];
int *array;
int number;
// asking the user to enter a filename, the file will readthe conents
printf("Please enter a filename for input:");
scanf("%s", &filename);
pFile = fopen(filename, "r");
if (pFile == NULL)
{
printf ("Error openingfile! ");
return -1;
}
while (!feof(pFile))
{
fscanf(pFile, "%s ", data);
createCourse(data,number);
}
fclose(pFile);
return 0;
}