A short programming puzzle [closed]
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);
}
output.
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*.
加载中,请稍侯......
精彩评论