// C
typedef struct {
ElemSet e1;
ElemSet e2;
ElemSet e3;
}Triplet;
//
Status InitTriplet(Triplet *t,ElemSet v1,ElemSet v2,ElemSet v3) {
//
t = (Triplet *)malloc(sizeof(Triplet));
if (!t) {
//
return ERROR;
}
t->e1 = v1;
t->e2 = v2;
t->e3 = v3;
return OK;
}
int main(int argc, const char * argv[]) {
// insert code here...
Triplet t;
InitTriplet(&t, 10, 15, 20);
printf("%p\n", &t);
printf("%d\n", t.e2);
t.e2 = 100;
printf("%d\n", t.e2);
return 0;
}
Why do I initialize it through the InitTriplet method and then get a value of 0 for e2 instead of the 15 I passed in?