考虑下面的C程序段。
# include
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
这个问题的测验