C - Building an array of pointers

Introduction

An array of pointers is an array that holds memory locations.

An array of pointers is really an array of strings in the following code.

Demo

#include <stdio.h> 

int main() /*  www .j av  a2 s.co m*/
{ 
   char *fruit[] = { 
       "abc", 
       "def", 
       "pear", 
       "apple", 
       "Java", 
       "XML", 
       "CSS" 
   }; 
   int x; 

   for(x=0;x<7;x++) 
       puts(fruit[x]); 

   //replace the array notation with pointer notation. 
   for(x=0;x<7;x++)
       puts(*(fruit+x));
   return(0); 
}

Result

Related Topic