I need some help with a program I am writing:
Write a program that will allow the user to enter the results of TEST1 for (Computing Systems and Programming) subject and store them in a data file named TEST1.txt. The data file “TEST1.txt” should have the following format:
And this is what I've done so far:
Matric No. Name Marks
I have been trying to fix the code so you may or may not need the commented lines. What I would like to know is what's wrong and why it can't produce the required output.
#define FILENAME "data.txt"
int main (void)
printf ("How many students would you like to place record for?\n");
scanf ("%d", &num);
datatab = fopen (FILENAME,"a");
if (datatab == NULL)
printf ("Error opening File\n");
printf ("num = %d\n",num);
int i = 0;
printf ("i = %d\n",i);
printf ("Please Enter name(Less than 50 Characters:\n");
printf ("Please Enter Matric Number:\n");
printf ("Please Enter Marks Obtained (via Cheating or otherwise):\n");
fprintf (datatab,"%d %s %.2f\n", matric,name,marks);
Matric number ex: 0987674 (I want the zero to be displayed)
Name ex: Anything (Just the first name would be enough).
Marks ex: 67.89 (Maximum of 2 digit decimal)