struct point {
int x;
int y;
};
main() {
struct point a;
a.x = 5;
a.y = 10;
printf("%d %d", a.x, a.y);
}
Output:
5 10
Here if I want add a member (int z
) int the same structure dynamically.
What is the procedure?
What I have tried:
struct point {
int x;
int y;
};
struct newpoint {
struct point a;
int z;
};
I have tried the above steps, through which we have added a new member and the old structure point
to new structure newpoint
. But this is not what I want, I want to add the new member the same structure dynamically. I got this question in an interview.