Can anybody explain how its printing output as "ink"
c, obfuscation, pointers
Solution
Let's trace it:
ptr = {pointer to "violet", pointer to "pink", pointer to "white", pointer to "black"}
p = ptr --> *p = pointer to "violet"
++p --> *p = pointer to "pink"
This implies that:
*p = {'p','i','n','k','\0'}
Which means:
**p = 'p'
**p + 1 = 'i'
so `**p + 1` is a pointer to this string: `{'i', 'n', 'k', '\0'}`, which is simply `"ink"`.
Problem
I am new to pointers in C. I know the basic concepts. In the below code, why is it printing the "ink" as its output? ``` #include<stdio.h> main() { static char *s[]={"black","white","pink","violet"}; char **ptr[]={s+3,s+2,s+1,s},***p; p=ptr; ++p; printf("%s",**p+1); } ``` Thanks