9.Which expression in following statements is not correct?( )A.char str[10]; str="string";B.char str[ ]="string";C.char *p="string";D.char *p; p="string";请说明原因谢谢12.Which is the output result of the following program code(

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/17 23:51:31
9.Which expression in following statements is not correct?( )A.char str[10]; str=
xSNA} Ȧ\Xӊx/ninvxVm)?Q-nEޅU_ofm/4i;}眝 }cp /D帐@ xbJH"‚$aaEnQ[B씞LN˃!x@P`fF}b#9 j7~؍s\*޷5Mu,%#!I䢂(>DIXBK>ƒ3ii@5en΃R7B%bz]NARwȕcS yt4\{+qKh~r˩y5 CWvׂt? Tv:-ig%ot҆e_Yzݪ,z>[_:NҷMK_ ne^s9GNܟ7 7[7se@83G7k)]lbu ['Pj{.p>;sft 3pN@1O̝g*.6Kiֶ/6k*d62W/Y_ t5u@`LFA8ڷnL@rΫ 6Ib^g}ܭ%H?ҨJ.^ }aKDywMw|e Z~ b(1Mn/|

9.Which expression in following statements is not correct?( )A.char str[10]; str="string";B.char str[ ]="string";C.char *p="string";D.char *p; p="string";请说明原因谢谢12.Which is the output result of the following program code(
9.Which expression in following statements is not correct?( )
A.char str[10]; str="string";
B.char str[ ]="string";
C.char *p="string";
D.char *p; p="string";
请说明原因谢谢
12.Which is the output result of the following program code( )
char s[ ]="student";
printf(“%s%d”,s+3,sizeof(s));
A.student7 B. dent7 C.dent8 D.student8
这题答案是什么呢

9.Which expression in following statements is not correct?( )A.char str[10]; str="string";B.char str[ ]="string";C.char *p="string";D.char *p; p="string";请说明原因谢谢12.Which is the output result of the following program code(
9.char str[10];这个定义系统分配了一个连续的存储空间给数组,str是一个数组名,是数组的首地址,数组的首地址分配了就不会改变了,所以str就是一个常量指针了,就不能再继续赋值了.至于B答案,那是因为没有给数组分配存储空间,而只是一个声明,就相当于一个指针.
答案是C.
s是字符串的首地址指向的是s,而是s+3指向的是d,所以输出的是dent,遇到了字符串结束字符就结束了.
sizeof()求的是字符串所占的字节数,字符串"student"其实是"student\0"共8个字符.