有以下程序 #include main() { char p[]={′a′, ′b′, ′c′},q[10]={ ′a′, ′b′, ′c′}; printf("%d%d\n",strlen(p),strlen(q));} 以下叙述中正确的是

admin2010-09-05  18

问题 有以下程序
#include
main()
{  char p[]={′a′, ′b′, ′c′},q[10]={ ′a′, ′b′, ′c′};
printf("%d%d\n",strlen(p),strlen(q));}
以下叙述中正确的是

选项 A、在给p和q数组置初值时,系统会自动添加字符串结束符,故输出的长度都为3
B、由于p数组中没有字符串结束符,长度不能确定,但q数组中字符串长度为3
C、由于q数组中没有字符串结束符,长度不能确定,但p数组中字符串长度为3
D、由于p和q数组中都没有字符串结束符,故长度都不能确定

答案A

解析 在给p和q数组赋初值时,系统会自动添加字符串结束符,从题目中可以看出数组p和q都有3个字符,所以长度均为3。
转载请注明原文地址:https://kaotiyun.com/show/ASWp777K
0

相关试题推荐
最新回复(0)