大门|大门-CS-2015(第三组)|问题65

考虑下面的C程序段。

null

# include <stdio.h>
int main( )
{
char s1[7] = "1234" , *p;
p = s1 + 2;
*p = '0' ;
printf ( "%s" , s1);
}


程序将打印什么?

(A) 12

(B) 120400 (C) 1204 (D) 1034 答复: (C) 说明:

    char s1[7] = "1234", *p;
    p = s1 + 2;    // p holds address of character 3
    *p = '0' ;   // memory at s1 + 3 now becomes 0
    printf ("%s", s1);  // All characters are printed

这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享