Pointers to Structures
The way we can have a pointer pointing to an int, or a pointer pointing to a char, similarly we can have a pointer pointing to a struct. Such pointers are known as ‘structure pointers’.
Let us look at a program that demonstrates the usage of a structure pointer.
Example
int main() { struct book { char name[25]; char author[25]; int callno; }; struct book b1 = { "The C book", "ABC", 2101 }; struct book *ptr; ptr = &b1; printf("\n%s %s %d", b1.name, b1.author, b1.callno); printf("\n%s %s %d", ptr->name, ptr->author, ptr->callno); getchar(); return 0; }