I have been racking my brain on trying to finish this homework.
I am getting an error right where I start my FOR loop. (subscript requires array or pointer type)
I don't know what I am doing wrong, I modified a working code and added my code to it, but I can't compile it. Anyone please help!!
thanks!
Code:
{
struct felix
{
int empno;
float wages;
};
felix record;
int i;
FILE *main_file;
main_file = fopen("master_f", "wb");
fprintf(stdout, "Enter employee numbers and wages: \n");
fprintf(stdout, "When done, enter a zero twice \n");
fscanf(stdin, " %s %f", &record.empno, &record.wages);//Stdin is the file pointer
for(i = 0; record.empno[0] != '0'; ++i)
{
fprintf(main_file, " %s %f \n", record.empno, record.wages);//Write to the file
fscanf(stdin, " %s %f", &record.empno, &record.wages);
}
fclose(main_file);//This should be last pertaining to file open and close.
fprintf(stdout, "There were %d records entered\n", i);
}