Hi everyone, I am having some trouble here...
I am asking the user to enter a file, and that file will read the contents and determine if the student will pass or fail the class.
That part I am having trouble with is when I have to decide if the student passes or fails the class.
#include <stdio.h>
int main()
{
FILE* pFile = NULL;
int nsid = 0;
char lastname[255];
char filename[80];
float midterm = 0;
float final = 0;
float wavg = 0;
char decision[80];
// asking the user to enter a filename, the file will read the conents
printf("Please enter a filename for input: ");
scanf("%s", &filename);
pFile = fopen(filename, "r");
if (pFile == NULL)
{
printf ("Error opening file!\n");
return -1;
}
//the file will read nsid, lastname, midterm, and final marks then calculate the weighted average and decide if the student passes
printf("%-10s %-10s %-10s %-10s %-10s %-10s\n", "nsid" , "lastname" , "midterm" , "final" , "w.avg" , "decision");
while (!feof(pFile))
{
fscanf(pFile, "%d %s %f %f\n", &nsid, lastname, &midterm, &final);
//weighted average is calculated
wavg = (midterm * 0.45) + (final * 0.60);
//problem starts here
if (wavg > 50.00)
{
char (&decision = "PASSED");
}
else
{
char (&decision = "FAILED");
}
printf("%-10d %-10s %-10f %-10f %-10f %-10s \n", nsid, lastname, midterm, final, wavg, decision);
}
fclose(pFile);
return 0;
}
These are the errors it shows:
a2.c: In function ‘main’:
a2.c:36: error: expected identifier or ‘(’ before ‘&’ token
a2.c:40: error: expected identifier or ‘(’ before ‘&’ token
Can anyone please help?