Use pointers to display the strings pointed by the array elements of an array of pointers

/*Program using pointers to display the strings pointed by the array el-
ements of an array of pointers*/
 
#include <stdio.h>
 
int main()
{
    /*Define and Initialize the 2-D array*/
    char *direction[]={
           "North",
           "East",
           "West",
           "South",
  };
 
  int i;
  const int SIZE = (int) sizeof(direction)/sizeof(direction[0]);
 
  /*Print*/
  for(i=0;i<SIZE;i++)
           printf("%s%c",direction[i],(i<SIZE-1)? ' ' : 'n');
 
  return 0;
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.