Consider the question of writing a function, Month_name (n), which returns a pointer to a string of nth-month names. This is an ideal application for an array of internal static types. The Month_name function contains a private array of strings that, when called, returns a pointer to the correct element.
The initialization syntax for a pointer array is similar to the initialization syntax for the other types of objects described earlier:
Char*month_name (intN) { Static Char*name[]={ "Illegal month", "January","February","March", "April"," May","June", "July","August","September", "October","November","December" }; return(n<1|| N> A)? name[0]:name[n];}
Where the declaration of name is the same as the declaration of lineptr in the sort example, is a one-dimensional array, and the elements of the array are character pointers. The initialization of the name array is implemented by a string list that assigns each string in the list to the element at the corresponding position in the array. All characters of the I string are stored in a location in memory, and pointers to it are stored in name[i]. Since the length of the array name is not specified in the above declaration, the compiler compiles the number of initial values and fills the exact number into the length of the array.
Initialization of an array of pointers