考虑以下 C 程序段。
# include
int main( )
{
char s1[7] = "1234", *p;
p = s1 + 2;
*p = '0' ;
printf ("%s", s1);
}
程序会打印什么?
(一) 12
(乙) 120400
(三) 1204
(四) 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
这个问题的测验