#include <stdio.h>
#define LENGTH 3
char *words[LENGTH];
int main( int argc, char *argv[] )
{
char *pc; // a pointer to a character
char **ppc; // a pointer to a pointer character
printf( "\n------------Multiple indirection example\n" );
// initialize our array string
words[0] = "zero";
words[1] = "one";
words[2] = "two";
// print each element
for ( int i = 0; i < LENGTH; ++i )
{
printf( "%s \n", words[i] );
}
ppc = words; // initialize the pointer to pointer to a character
for( int i = 0; i < LENGTH; ++i) // loop over each string
{
ppc = words + i;
pc = *ppc;
while (*pc != 0) { // process each character in a string
printf("%c ", *pc); // print out each character of the string individually
pc += 1;
}
printf("\n");
}
return 0;
}
The part that says " char **ppc " declares a char double pointer. Then it says ppc = word . What is the difference between a regular pointer variable being assigned to words and this double pointer variable? I also don't get why a regular pointer variable would be assigned to have the value of a double pointer variable. Can someone explain this?