I am writing a program that is supposed to read info from a file clock.txt that has the number of employees then a name and then payrate and then another name and payrate. I have a struct
Code:
struct employee {
char* first[MAX_LEN];
char* last [MAX_LEN];
double payperhr;
double taxes;
double hours_in_week;
};
the information im suppose to read in is
2
john slacker 5.15
jane worker 10
now i have
Code:
void scanclock(struct employee a){
int i;
int week, employee_day;
double minin,hrin;
double minout,hrout;
int num_employee;
FILE* fp;
fp = fopen("clock.txt", "r");
fscanf(fp, "%d", num_employee);
for(i=0; i<=num_employee; i++)
{
fscanf(fp, "%s%s%d", &a.first[i], &a.last[i], &a.payperhr);
}
fscanf(fp, "%d", &week);
for(i=1; i<=week; i++)
{
fscanf(fp, "%d", &employee_day);
fscanf(fp, "lf%lf%lf%lf", &minin, &hrin, &minout, &hrout);
}
fclose(fp);
I wanted to see if this either looks ok... and does it seem like im going down the right path? a.payperhr does that need to be strcpy and.... and should i keep it in a function or possibly better to do this in int main?