开发者

A short programming puzzle [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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*.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜