What could the possible explanation for the following puzzle :
#include <stdio.h>
int main(){
static char *s[] = {"black","white","yellow","violet"};
char *ptr[] = {s+3,s+2,s+1,s},***p;
p = ptr;
*++p;
printf("%s",*--*++p + 3);
}
What could the possible explanation for the following puzzle :
#include <stdio.h>
int main(){
static char *s[] = {"black","white","yellow","violet"};
char *ptr[] = {s+3,s+2,s+1,s},***p;
p = ptr;
*++p;
printf("%s",*--*++p + 3);
}
p = ptr;
This is not a puzzle. It's an invalid piece of code since it assigned a char**
to a char***
. Actually the problem happens in the array declaration
s+3
has type char**
, but you declare ptr
as an array of char*
.