I am trying to replace the input from the user in the function readEmployee and replace that with the information that is in struct employee e. Does anyone know if that is possible. i am trying to get the output to be whatever the user inputs in the readEmployee function and to do that it needs to replace the information that i have set as a test in the struct employee e. If anyone can help that would be great. Thanks,
CODE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct employee
{
char *name;
char ssn[9];
int YearBorn;
int salary;
};
struct employee e = {"Kyle", "689543598", 1900, 100000};
void display(struct employee e)
{
printf("\n%s , %3.3s-%2.2s-%4.4s , %d\n", e.name, e.ssn, e.ssn + 3, e.ssn + 5, e.YearBorn);
printf("$%d,%.3d\n", e.salary/1000, e.salary%1000);
}
void readEmployee(struct employee e)
{
e.name = (char*)malloc(100);
printf("\nEmployee Name: ");
gets(e.name);
strncpy(*name, e.name);
printf("\nEmployee SSN: ");
gets(e.ssn);
strncpy(ssn, e.ssn);
printf("\nEnter Year you were born: ");
scanf("%d", &e.YearBorn);
strncpy(YearBorn, e.YearBorn);
printf("\nPlease enter Employee Salary: ");
scanf("%d", &e.salary);
strncpy(salary, e.salary);
}
int main()
{
readEmployee(e);
display(e);
return 0;
}