We're supposed to have an array that stores every employee that is created, but i dont know how to create/'name' new employee's on the fly.
Does scanf on each index on the array doesn't solve your problem?
So my real question I guess is how do i set up my function call and definition?
Since I don't know what your structure looks like I'll make this example
struct x
{
int a;
int b;
};
main()
{
struct x z;
z.a = 5;
printf("The first member is %d \n", z.a);
}
could you post your code for more details?
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14
Heres a more relevant example to your structure
struct emp{ //example structure
char name[20];
};
void add(struct emp *employee,int n){
int i;
for(i=1;i<=n;i++){
printf("Enter employee %i",i); //my example on receiving input
printf("\nEnter name:");
scanf("%s",employee[i].name);
}
}
main()
{
int num = 5; //defined number of employees
struct emp employee[1000];
add(employee, num);
}
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14
Question Answered as of 1 Year Ago by
zeroliken