How can I use struct pointers with designated initialization? For example, I know how to init the struct using the dot operator and designated initialization like:
person per = { .x = 10,.y = 10 };
But If I want to do it with struct pointer?
I made this but it didn't work:
pper = (pperson*){10,5};
You can use a pointer to a compound literal:
struct NODE{
int x;
int y;
}
struct NODE *nodePtr = &(struct NODE) {
.x = 20,
.y = 10
};