I'm having trouble initializing a struct that has a union in it also. I tried following a few guides and it seems like I'm it correctly, obviously not though if it's not working.
I have the following header
#ifndef MENU_H_
#define MENU_H_
typedef struct student{
int gpa;
float tuitionFees;
int numCourses;
}student;
typedef struct employee{
float salary;
int serviceYears;
int level;
}employee;
typedef struct person{
char firstName[20];
char familyName[20];
char telephoneNum[10];
int type; // 0 = student / 1 = employee;
union{
employee e;
student s;
};
}newPerson;
#endif
And then this is what I'm having trouble with
newPerson person[MAX_PERSONS];
person[1] = {"geo", "dude", "6136544565", 0, {3, 2353, 234}};
when I try to initialize person[1], I get the following error
error: expected expression before ‘{’ token
I was wondering what the cause of this might be? Does not seem like I'm missing a brace, I also tried to remove the inner braces but it still does not work. Any help would be very much appreciated. Thank you