I have the following code -
#include <stdio.h>
#define LENGTH 5
int main(){
char* ch[LENGTH] = {"Zero", "One", "Two", "Three", "Four"};
char* pc;
char** ppc;
for(int i=0; i<LENGTH; i++){
ppc = ch+i;
pc = *ppc;
while(*pc != 0){
printf("%c ", *pc);
pc = pc +1;
}
printf("\n");
}
return 0;
}
It is an example of multiple indirection using string.
The output is
Z e r o
O n e
T w o
T h r e e
F o u r
Here in while()
loop instead of *pc != '\0'
, *pc != 0
is used.
But both the approaches give same output. Why is it so?