Pointers to Struct and Unions in C

I lost the post-it note from my monitor.

(*x).y is the same as x->y

For example:

struct myStructDef {
uint8_t data;
};

struct myStructDef myStruct1;
struct myStructDef *myStruct2;
myStruct2 = &myStruct1;

(*myStruct2).data = 0;
myStruct2->data = 0; /* the same */

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s