Retrieve Strings Using a Pointer to a Pointer, a pointer to pointer to char type array - C Pointer

C examples for Pointer:Array Pointer

Description

Retrieve Strings Using a Pointer to a Pointer, a pointer to pointer to char type array

Demo Code

#include <stdio.h>

int main()/* w w  w .jav  a2s. co m*/
{
      char ch;
      char cities[5][10] = {
                                    "11111",
                                    "1111",
                                    "111",
                                    "11",
                                    "1"
                               };
      char *ptr, **ptrPtr;
    
      ptrPtr = &ptr;
    
     for(int i=0; i<5; i++) {
          ptr = (char *) cities[i];
          int j = 0;
    
          do {
                ch = *(ptr + j);
                printf("%c", ch);
                j = j + 1;
          } while(ch != '\0');
          printf("\t\t");
          j = 0;
        
          do {
                ch = *(*ptrPtr + j);
                printf("%c", ch);
                j = j + 1;
          } while(ch != '\0');
        
          printf("\n");
     }
    
     return(0);
}

Result


Related Tutorials