799 views
3 votes
3 votes
#include <stdio.h>
char *str[]={"FirstSring","Is","Already","Written"};
char **strp[]={str+3,str+2,str+1,str};
char ***strpp=strp;
int main(void) 
{
        printf("%s",**++strpp);
        printf("%s",*--*++strpp+3);
        return 0;
}

Output of this, and the interpretation?

1 Answer

Best answer
8 votes
8 votes
#include <stdio.h>

char *str[]={"FirstString","Is","Already","Written"};
// str is an array of char pointers
char **strp[]={str+3,str+2,str+1,str};
// strp is an array of pointers and those pointers point to char
// simply strp is array of pointers
char ***strpp=strp;
// strpp is pointer variable which store address of another pointer

int main(void)  {
		printf("%s",**++strpp); // Already
		
		printf("%s",*--*++strpp+3); //stString

		// (*(--(*(++strpp))))+3 
		// ++ has higher precedence than binary +
		// * has higher precedence than binary +
		// -- has higher precedence than binary +
		
		return 0;
}
// final OP : AlreadystString

Now, Assuming character takes 1 Byte and pointer variable takes 4 Bytes.

  1. char *p ; increment on p will take place in $1$ Byte step
  2. char **p (Or, any double pointer): increment will take place in $4$ Byte step.

edited by

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2