Pointers To String

Pointer to array of string : A pointer which pointing to an array which content is string, is known as pointer to array of strings.
In this example
  1. ptr      : It is pointer to array of string of size 4.
  2. array[4] : It is an array and its content are string.

1 : Printing Address of the Character Array

#include<stdio.h>

int main()
{
int i;

char *arr[4] = {"C","C++","Java","VBA"};
char *(*ptr)[4] = &arr;

for(i=0;i<4;i++)
    printf("Address of String %d : %u\n",i+1,(*ptr)[i]);

return 0;
}
Output :
Address of String 1 = 178
Address of String 2 = 180
Address of String 3 = 184
Address of String 4 = 189

2. Printing Contents of character array

#include<stdio.h>

int main()
{
int i;

char *arr[4] = {"C","C++","Java","VBA"};
char *(*ptr)[4] = &arr;

for(i=0;i<4;i++)
    printf("String %d : %s\n",i+1,(*ptr)[i]);

return 0;
}
Output :
String 1 = C
String 2 = C++
String 3 = Java
String 4 = VBA

3. Pointer to String and Pre-increment Operator

#include<stdio.h>

int main()
{
int i;

char *arr[4] = {"C","C++","Java","VBA"};
char *(*ptr)[4] = &arr;

printf("%s",++(*ptr)[2]);

return 0;
}
Output:
ava