#include <stdio.h>
#define SIZE 20
#define MAX_LEN 30
struct employee {
char first[MAX_LEN];
char last[MAX_LEN];
double payperhr;
double gross;
double taxes;
double hours_in_week;
};
int main() {
int i, j, n, k, m, hrin, minin, hrout, minout, temphours;
char first, last, L;
FILE* ifp;
ifp = fopen("clock2.txt","r");
struct employee workers[SIZE];
for (i=0; i<n; i++) {
fscanf (ifp,"%s%s%lf", workers [i].first, workers [i].last, workers [i].payperhr);
}
fscanf(ifp,"%d", &k);
for(i=0; i<k; i++) {
for(j=0; j<n; j++) {
workers [j].hours_in_week = 0;
}
fscanf(ifp, "%d", &m);
for(i=0; i<m; i++) {
fscanf(ifp, "%s%s%d%d%d%d", last, first, &hrin, &minin, &hrout, &minout);
temphours = calc_hours(hrin, minin, hrout, minout);
for(L=0; L<n; L++) {
if(strtcmp(first, workers[L].first) == 0 && (last, workers[L].last) == 0) {
workers[L] += temphours; //line where I receive the error
}
}
}
for(j=0; j<n; j++) {
if(workers[j].hours_in_week > 40) {
workers [j].gross += (40 * workers[j].payperhr) + (workers[j].hours_in_week
-40) * 1.5 * workers[j].payperhr;
workers[j].taxes += 0.1 * (40 * workers[j].payperhr) + 0.2 *
(workers[j].hours_in_week - 40) * 1.5 * workers[j].payperhr;
}
}
}
fclose(ifp);
FILE *ofp;
ofp = fopen("w2.txt", "w");
fprintf(ofp, "w2 Form\n");
fprintf(ofp, "-------\n");
for(j=0; j<n; j++)
fprintf(ofp, "Name %s %s\n", workers[j].first, workers[j].last);
fprintf(ofp, "Gross Pay %lf\n", workers[j].gross);
fprintf(ofp, "Taxes Withheld %lf\n", workers[j].taxes);
fprintf(ofp, "Net Pay %lf", workers[j].gross - workers[j].taxes);
system("PAUSE");
return 0;
}
double calchours(int hrin, int minin, int hrout, int minout) {
int hours = hrout - hrin;
int min = minout - minin;
if(min < 0) {
min += 60;
hours--;
}
double tothours = hours + 1.0 * min/60;
return tothours;
}
I apologize for my stying if it's difficult to read. Line 46 is where I receive the error. Thanks in advance for any help

New Topic/Question
Reply




MultiQuote







|