meili 发表于 2022-10-27 16:09:03

【求详细的解释一道编程题执行下列程序后,输出的第一行为,第二行为。#includeintfun(char*s){char*p=s;while(*p)p++;return(p-s);}voidmain(){chars1[]=quot;Chinaquot;,s2[]=quot;ApplenPeartCatByequot;;cout】

<p>问题:【求详细的解释一道编程题执行下列程序后,输出的第一行为,第二行为。#includeintfun(char*s){char*p=s;while(*p)p++;return(p-s);}voidmain(){chars1[]=quot;Chinaquot;,s2[]=quot;ApplenPeartCatByequot;;cout】
<p>答案:↓↓↓<p class="nav-title mt10" style="border-top:1px solid #ccc;padding-top: 10px;">茅剑锋的回答:<div class="content-b">网友采纳  sizeof的值是占内存大小s1占内存5+1=6个字节,(结束符也占一个字节)s2占内存19个字节fun函数的作用和strlen的作用一样s1里有5个字符s2遇到结束,有14个字符ApplenPeartCat
页: [1]
查看完整版本: 【求详细的解释一道编程题执行下列程序后,输出的第一行为,第二行为。#includeintfun(char*s){char*p=s;while(*p)p++;return(p-s);}voidmain(){chars1[]=quot;Chinaquot;,s2[]=quot;ApplenPeartCatByequot;;cout】