Code:
#include <stdio.h>
#include <string.h>
#define SIZE 81
#define SIZEPAY 81
int main(void)
{
FILE *fp, *fpPay;
char *status, *statusPay;
struct
{
char employeeNum[10];
char lastName[25];
char firstName[25];
char jobCode[5];
char payCode[3];
} group[SIZE];
struct
{
char payCode[3];
char payAmount[8];
} payRate[SIZEPAY];
int trial2 = 0;
int i, sz[] = {0,9,24,24,4,2};
int y, szPayRate[] = {0,2,7};
char buff[1024];
char buff3[1024];
fp = fopen("Employee.txt","r");
fpPay = fopen("payR.txt","r");
status = fgets(buff, sizeof(buff), fp);
statusPay = fgets(buff3, sizeof(buff3), fpPay);
while (statusPay != NULL){
strncpy(payRate[y].payCode, strtok(buff3,","),szPayRate[1]);
strncpy(payRate[y].payAmount, strtok(NULL,","),szPayRate[2]);
statusPay = fgets(buff3,sizeof(buff3),fpPay);
y++;
}
while (status != NULL)
{
strncpy(group[i].employeeNum, strtok(buff," "), sz[1]);
strncpy(group[i].lastName, strtok(NULL," "), sz[2]);
strncpy(group[i].firstName, strtok(NULL," "), sz[3]);
strncpy(group[i].jobCode, strtok(NULL," "), sz[4]);
strncpy(group[i].payCode, strtok(NULL," "), sz[5]);
for(trial2 = 0; trial2<16;trial2++)
{
if(strcmp(group[i].payCode, payRate[trial].payCode) == 0)
{
fputs(group[i].payCode, stdout);
fputs("\t",stdout);
fputs(payRate[trial].payAmount, stdout);
}
}
status = fgets(buff,sizeof(buff),fp);
trial2 = 0;
i++;
}
fclose(fp);
fclose(fpPay);
return 0;
getchar();
}
Unfortunately now, The output is not what I am asking.