Display the first characters of the strings pointed by the array elements 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("%c",direction[i][0]);
  return 0;
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.