Computer >> Computer tutorials >  >> Programming >> C programming

How many levels of pointers can we have in C/C++?


Actually, C programs one or two static levels of pointers are common. Triple indirection is rare. But infinite is very common. Infinite pointer indirection can be achieved with the help of a struct.

struct list { struct list *next; ... } lst; lst->next->next->next->...->next

and in this way we can implement multiple pointer indirection.

There is another alternative notation as shown below

– *(*(..(*(*(*lst).next).next).next...).next).next