Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

Pointers to structures in embedded C

Sometimes you might like to manipulate the members of C structures in more generalized way. This can be done by using pointer reference to structure. Normally it is easier to pass pointer to structure than passing entire structure to function.

Structure pointer can be declared very easily:

struct structure_tag_name *variable;

For instance:

struct position{

int x;

int y;

}pos1, *pos2;

we can assign first structure address to structure pointer like this:


now we can access first structure members by using structure pointer:


or we can write


Structures can contain member pointers to other structures or to structures of same type. This way we can create lists – dynamic structure:

struct list{

int listNo;

struct list *next; //pointer to another structure

}item1, item2;

This way you can assign the pointer with address to another structure:


Read more about dynamic structures in C tutorials on internet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.