hi I wonder if array can be work along with structure?
Below are the declaration of my structure
struct employee{
char ID[15];
char Name[20];
char Department[5][30];
int selection;
char Post[3][30];
};
struct employee record[200];
I was wondering could if there is anywhere you can :
struct employee{
char ID[15];
char Name[20];
char Department[5][30]={"Accounting","Administration","Management","Human resource","Others"};
int selection;
char Post[3][30];
};
struct employee record[200];
because the problem is when I wanted to store this data , below is the declaration of arrays within the add_record function
char Department[5][30]={"Accounting","Administration","Management","Human Resource","Others"};
Here i use to capture the inputs and department as selection :
printf("\n\n 0) %s\n 1) %s\n 2) %s\n 3) %s\n\n [Enter Department for this new employee]: ", Department[0], Department[1], Department[2], Department[3]);
fflush(stdin);
scanf("%d", &selection);
if((selection != 0) && (selection != 1) && (selection !=2) && (selection !=3)) {gotoxy(1, 24); printf(" >>invalid Department<< Retry!\a");}
} while(selection < 0 || selection > 3);
clrscr();
printf("\n Enter The new ID for this employee: ");
fflush(stdin);
gets(ID);
printf("\n Employee Name : ");
fflush(stdin);
gets(Name);
You can only display the contents such as Accounting, Administration when you printf as Department[selection]
But how should I do if i want it "for example Management" to store in the structure so that next time when I printf Department for that particular record in other function it would appear as Management and not blank because mine when I printf it on other function it is null?