Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Programming I am trying to get a program that will create a temporary struct t

ID: 3858089 • Letter: C

Question

C Programming

I am trying to get a program that will create a temporary struct that reads information from a command line argument file into a temporary struct and then passes that information to a function that adds it to the end of a dynamically allocated list, and repeats until the end of the file is reached.

Thank you

int buildEmployeeList (struct employee listl, char* filename) { "r"); FILE * f= fopen (filename, if (f NULL) return-1 ; int i = 0; while(!feof (f) &&ferror; (E)) struct employee temp; int num = fscanf(f, "%s %d %lf %1f ", temp . name , if (num 4) &temp.id;, &temp; .hoursworked, &temp.hourlyRate; ); printf ("Didn't read enough values from input file line %d " , i); list[i++ tempi fclose (E) return i

Explanation / Answer

The program you need is as follows. I tried to keep it simple and easy with only using standard libraries.Hope you'll like it.Here goes the code.

Employee.c

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct empo
{
char eName[22];
char city[20];
int hoursWorked;
int hourlyRate;
};
void main()
{
struct empo employee[5];
FILE *f;
int uu;
int maximum;
clrscr();
printf("ENTER THE FOLLOWING INFORMATION OF 5 EMPLOYEES ");
for(uu=0;uu<5;uu++)
{
printf("Name:");
scanf("%s",&employee[uu].eName);
printf("City:");
scanf("%s",&employee[uu].city);
printf("hours Worked:");
scanf("%d",&employee[uu].hoursWorked);
printf("hourly Rate:");
scanf("%d",&employee[uu].hourlyRate);
}
f=fopen("empo.dat","r");
for(uu=0;uu<5;uu++)
{
fprintf(f,"%s ",employee[uu].eName);
fprintf(f,"%s ",employee[uu].city);
fprintf(f,"%d ",employee[uu].hoursWorked);
fprintf(f,"%d ",employee[uu].hourlyRate);
}
fclose(f);
f=fopen("empo.dat","r");
if(f == NULL)
{
return -1;
exit(0);
}
for(uu=0;uu<5;uu++)
{
fscanf(f,"%s",&employee[uu].eName);
fscanf(f,"%s",&employee[uu].city);
fscanf(f,"%d",&employee[uu].hoursWorked);
fscanf(f,"%d",&employee[uu].hourlyRate);
}
maximum=employee[0].hourlyRate;
for(uu=0;uu<5;uu++)
{
if(employee[uu].hourlyRate>=maximum)
maximum=employee[uu].hourlyRate;
}
printf(" MAXIMUM hourlyRate PAID TO empo: ");
for(uu=0;uu<5;uu++)
if(employee[uu].hourlyRate==maximum)
{
printf(" NAME:%s",employee[uu].eName);
printf(" CITY:%s",employee[uu].city);
printf(" HOURS WORKED:%d",employee[uu].hoursWorked);
printf(" HOURLY RATE:%d",employee[uu].hourlyRate);
}
getch();
}

Please rate the answer if it helped......Thankyou

Hope it helps.....