How to declare a structure pointer in C?

For a structure:

struct address


char name[60];

char street[100];

char city[50];

char state[40];

char country[40];

long int zip;


To declare a structure pointer:

struct address *address_pointer;

Uses of structure pointers:

1) For the creation of linked lists and other dynamic data structures that depends on dynamic allocation.

2) To pass a structure to a given function using call by reference method.

Advantages of using structure pointers:

1) Fast function calls are possible.

2) Only address is passed and not the entire structure.

3) Even the contents of the structure can be modified by the function call.

Leave a Reply