Reputation: 2863
..then to an array, or along those lines. I'm so confused on what I'm supposed to do.
Here are the structs:
typedef struct {
char name[30];
} PersonType;
typedef struct {
PersonType *personInfo;
} StudentType;
typedef struct {
StudentType students[30];
} GraduateType;
I want to get the name of the PersonType. Something like this, in main():
GraduateType *gptr = (GraduateType *) calloc(3, sizeof(GraduateType));
// Assume here that info has been scanf()'d
int i, j;
for(i = 0; i < 3; i++) {
for(j = 0; j < 2; j++) {
if(strcmp(gptr[i].students[j].personInfo.name, "asd")) { // <- This
// blah
}
}
}
How?
Upvotes: 0
Views: 79
Reputation: 137422
You were almost there. personInfo
is a pointer, so you should treat it as such:
gptr[i].students[j].personInfo->name
Upvotes: 1