C |字符串|问题15

预测以下程序的输出,假设一个字符占用1字节,指针占用4字节。

null

#include <stdio.h>
int main()
{
char *str1 = "GeeksQuiz" ;
char str2[] = "GeeksQuiz" ;
printf ( "sizeof(str1) = %d, sizeof(str2) = %d" ,
sizeof (str1), sizeof (str2));
return 0;
}


(A) sizeof(str1)=10,sizeof(str2)=10

(B) sizeof(str1)=4,sizeof(str2)=10 (C) sizeof(str1)=4,sizeof(str2)=4 (D) sizeof(str1)=10,sizeof(str2)=4 答复: (B) 说明: str1是指针,str2是数组。 这个问题的小测验

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