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/12/19 13:29:48
main(){charstr[]="whatisyourname?";charname[20];printf("%s\n",str);scanf("%s",name);main(){charstr[]

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个元素内容为任意的