Code:
struct groups {
char name_group[NAMES];
char ID_group[NUMB];
char add_ID_employee[NUMB];
} group[MAX_GROUPS];
struct employees {
char name_employee[NAMES];
char ID_employee[NUMB];
} employee[MAX_EMPLOYEES];
I have this 2 structures.
I can add employees and add groups.
I want to link various employees to certain groups through they ID_employee.
I have this function to do that:
Code:
AddEmployeesGroup(){
int i=0, j=0, numb_employees;
char option_group[50];
printf("\nGROUPS IN THE SYSTEM:\n");
for(i=0;i<total_groups;i++){
printf("\n%s", group[i].name_group);
}
printf("\nEMPLOYEES IN THE SYSTEM:\n");
for(i=0;i<total_employees;i++){
printf("\nName: %s ID: %s", employee[i].ID_employee, pessoal[i].numero_id_pessoal);
}
printf("\nPick a group:\n");
scanf(" ");
gets(option_group);
/*search to see the position (i) of the group where I want to link
the ID of the employees*/
for(i=0;i<total_groups;i++){
if(strcmp(group[i].name_group, option_group) == 0)
break;
}
//now I know the position
printf("\nHow many employees do you want to add?\n");
scanf(" %i", &numb_employees);
for(j=0;j<numb_employees;j++){
printf("\nWhat's the ID of the employees that you want to add to shis group?:");
scanf(" ");
gets(group[i].add_ID_employee[PositionEmployees+j]);
//passing arg 1 of gets' makes pointer from integer without a cast
}
PositionEmployees=j;
}
The variable PositionEmployees is declared in the beggining of the program and is to detect the position that are occupied.
In the last gets is my problem, in theory this should work, i have the position (i) of the group and now I will only have to input the ID's of the employees to "add_ID_employee"
Can you guys give me any tips?