I have an array of structs created with an initial size and filled with the members of the struct tag. as such
Code:
struct employee{
char fullname[30];
float salary;
char fulldate[40];
};
struct employee my_employee[MAXSIZE]= {
{"Johnson, larry", 233333.3, "December, 4th 1999\n"},
{"Kobe, Bryant", 90999.23, "September, 3rd, 1922\n"},
{"Lebron, James", 43334.43, "January, 5th 1932"},
{"Jermaine, O'neal", 5556677.4, "January, 5th 1932"},
{"Dwayne, Wade", 55556.4, "January, 7th 1932"}
};
Then i want to use that array (my_employee in a function) that will add another struct and print all the details in the struct.
HERE IS MY CODE // WHY WONT THIS WORK
void add_employee(struct employee my_employee[]){
int i;
my_employee = malloc(200);
struct employee *tempRecs;
tempRecs = (struct employee *)malloc((size+1)*sizeof(struct employee));
memcpy(tempRecs, my_employee, size*sizeof(struct employee));
for(i = 0; i < size; i++) {
tempRecs[i] = (my_employee)[i];
}
printf("Please Enter Employee Full name:\n");
scanf("%s", tempRecs->fullname);
printf("Please Enter Employee salary");
scanf("%f", &tempRecs->salary);
printf("Please Enter Current Date (Month, DayYear)");
scanf("%s", tempRecs[size].fulldate);
size++;
free( my_employee);
my_employee = tempRecs;
}