Page 108 - 6437
P. 108

A variable that is a pointer to a pointer must be declared as such. This is done by placing
                   an  additional  asterisk  in  front  of  its  name.  For  example,  the  following  declaration  declares  a
                   pointer to a pointer of type int:
                          When a target value is indirectly pointed to by a pointer to a pointer, accessing that value

                 int **var;
                   requires that the asterisk operator be applied twice, as is shown below in the example:

                            #include <stdio.h>


                            int main ()
                            {

                                int  var;
                                int  *ptr;

                                int  **pptr;

                                var = 3000;


                                /* take the address of var */
                                ptr = &var;


                                /* take the address of ptr using address of operator & */
                                pptr = &ptr;


                                /* take the value using pptr */

                                printf("Value of var = %d\n", var );
                                printf("Value available at *ptr = %d\n", *ptr );

                                printf("Value available at **pptr = %d\n", **pptr);


                                return 0;
                            }

                          When the above code is compiled and executed, it produces the following result:








                                                                                                     111
   103   104   105   106   107   108   109   110   111   112   113