1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <stdio.h>
#include <string.h>
typedef struct EmpInfo
{
char firstname[10+1],lastname[15+1],fullname[25+1];
float payrate,hours, defr;
}EmpInfo;
void InputEmpData(EmpInfo theEmps[3]);
void DispalyData(EmpInfo theEmps[3]);
int main(void)
{
EmpInfo theEmps[3];
InputEmpData(&theEmps[3]);
DispalyData(&theEmps[3]);
fflush(stdin);
getchar();
return 0;
}
void InputEmpData(EmpInfo *theEmps[3])
{
for (int count = 0;count<3;count++)
{
printf("Enter employee's first name: ");
scanf("%s",theEmps[count]->firstname);
printf("Enter employee's last name: ");
scanf("%s",theEmps[count]->lastname);
printf("Enter hourly payrate: ");
scanf("%f",&theEmps[count]->payrate);
printf("Enter hours worked this pay peroid: ");
scanf("%f",&theEmps[count]->hours);
printf("Enter deferred amount:");
scanf("%f",&theEmps[count]->defr);
strcpy(theEmps[count]->fullname,theEmps[count]->lastname);
strcat(theEmps[count]->fullname,", ");
strcat(theEmps[count]->fullname,theEmps[count]->firstname);
}
}
void DispalyData(EmpInfo theEmps[3])
{
for(int count = 0;count<3;count++)
{
printf(" Name: %s\n",theEmps[count].fullname);
printf(" Payrate: %f\n",theEmps[count].payrate);
printf(" Hours: %f\n",theEmps[count].hours);
printf(" Deferred: %f\n",theEmps[count].defr);
}}
|