main() { char str[ ] ="what is your name ?"; char name [ 20]; printf("%s\n",str); scanf("%s",name);main() { char str[ ] ="what is your name ?"; char name [ 20]; printf("%s\n",str); scanf("%s",name); printf("\n my name is %s. \n",name);}在这程序

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 16:29:09
main() { char str[ ] =
xRjA~a!a]њ؆xV\K%M\]PVhP I̎Wy!zӛ9;ϙI2y%+V* DRJ$/DUȚN)sjeUIXh$CcWUI~G0 1څ懁[i3o鄗EQEQOWt%?d9!p7+AV:DS.Rdbdv2ǤLy_6,qܤ##rQm`5)X NX+c3ڮ70O>Cs{]-xdNޅ?FN¨)dt}̊ =Ij=;d]t@]L3 3dxbj›߹pDT[>lB? <̌t\+(j?ye

main() { char str[ ] ="what is your name ?"; char name [ 20]; printf("%s\n",str); scanf("%s",name);main() { char str[ ] ="what is your name ?"; char name [ 20]; printf("%s\n",str); scanf("%s",name); printf("\n my name is %s. \n",name);}在这程序
main() { char str[ ] ="what is your name ?"; char name [ 20]; printf("%s\n",str); scanf("%s",name);
main() {
char str[ ] ="what is your name ?";
char name [ 20];
printf("%s\n",str);
scanf("%s",name);
printf("\n my name is %s. \n",name);
}
在这程序中char name [20]是不是指程序运行后所要输入的名字和 “my name is ”中每个字符加起来不超过20个字符还是?char name [20]在程序中指的是?

main() { char str[ ] ="what is your name ?"; char name [ 20]; printf("%s\n",str); scanf("%s",name);main() { char str[ ] ="what is your name ?"; char name [ 20]; printf("%s\n",str); scanf("%s",name); printf("\n my name is %s. \n",name);}在这程序
不是你说的那个意思,这里的20只是表示这个数组一共有20个元素,也可以看成意思是这个数组占用内存为20个字符大小,my name is是这20个元素的一部分,如果你之前没有给字符串赋初值(你这里就是),那么s这个元素后面一个元素的内容是\0,再之后的9个元素内容为任意的