Skip to main content

Posts

Showing posts with the label Advanced Pointer Topics

Advanced Pointer Topics

Pointers to Pointers We introduced the concept of a pointer to a pointer previously. You can have a pointer to a pointer of any type. Consider the following: char ch; /* a character */ char *pch; /* a pointer to a character */ char **ppch; /* a pointer to a pointer to a character */ We can visualise this in Figure 11.1. Here we can see that  **ppch  refers to memory address of  *pch  which refers to the memory address of the variable  ch . But what does this mean in practice? Memory address Fig. 11.1 Pointers to pointers  Recall that  char *  refers to a ( NULL  terminated string. So one common and convenient notion is to declare a pointer to a pointer to a string (Figure 11.2) Pointer to Pointer Fig. 11.2 Pointer to String  Taking this one stage further we can have several strings being pointed to by the pointer (Figure  11.3 ) Pointer to String Fig. 11.3 Pointer to...