HI!
I am trying to do a homework assignment that is causing much frustration. The assignment is to sort through 4 arrays (emp_id[MAX], wage[MAX], hours[MAX], week_pay[MAX]. Calculate the week_pay and sort in descending order by emp_id. The problem I now have is that the program is not scanning the information. Here is the code I am using....
infile = fopen("a:\\empout.txt", "r");
if (infile = NULL)
{
print error msg
exit(1);
}
input_status = fscanf(infile, "%ld %f %f",&emp_id[index],&wage[index],&hours[index]);
while (input_status != MAX)
{
index = index + 1;
input_status = fscanf(infile, "%ld %f %f",&emp_id[index],&wage[index],&hours[index]);
}
*record_num = index;
fclose(infile);
}
I declared this functin as: void read_record(long *emp_id, float *wage, float*hours, int *record_num);
When I call the function: read_record(emp_id, wage, hours, &record_num);
Is there anything wrong with this code. When I run a watch these variables show the address no problem but nothing changes the info is not being scanned. This program basically crashes everytime. I can't find anything wrong with the code but maybe I'm missing something. Any help would be appreciated.
Thanks