Array of strings

Declaring array of pointers:

char *message[];

  • Each element of the array message[] is an individual pointer to type char. You can combine the declaration with initialization and allocation of storage space for the strings:

char *message[10] = { “one”, “two”, “three” };

This declaration does the following:
1.It allocates a 10-element array named message; each element of message is a pointer of type char.
2.It allocates space somewhere in memory (exactly where doesn’t concern you) and stores the three initialization strings, each with a terminating null character.
3.It initializes message[0] to point to the first character of the string “one”, message[1] to point to the first character of the string “two”, and message[2] to point to the first character of the string “three”.
Program to concatenate all the strings in a string array.


Mr. Sandeep Soni

Founder, Trainer & CEO, Deccansoft Software Services.

Sandeep has 21 yrs of experience working in various Microsoft Technologies/Platforms incl. VB6.0, ASP, VC++, VB.NET, C#. He is involved in managing and architecting projects at Deccansoft. He will be your liaison to Deccansoft, for any kind of communication and project updates. He knows what works and what doesn’t, and what practices are most suitable for design and programming with the ultimate goal of producing a quality system.