定义字符串数组
#include<stdio.h>
int main()
{
char a[]={'abcd'};
char c[]={"a bcd"};
char b[]={'a','b','c','d'};
printf("size of a = %d\n",sizeof(a));
printf("size of c = %d\n",sizeof(c));
printf("size of b = %d\n",sizeof(b));
printf("%s\n",c);
return 0;
}
结果:
size of a = 1
size of c = 6
size of b = 4
a bcd
--------------------------------
Process exited after 0.1593 seconds with return value 0
请按任意键继续. . .
int main()
{
char a[]={'abcd'};
char c[]={"a bcd"};
char b[]={'a','b','c','d'};
printf("size of a = %d\n",sizeof(a));
printf("size of c = %d\n",sizeof(c));
printf("size of b = %d\n",sizeof(b));
printf("%s\n",c);
return 0;
}
结果:
size of a = 1
size of c = 6
size of b = 4
a bcd
--------------------------------
Process exited after 0.1593 seconds with return value 0
请按任意键继续. . .
全部评论
相关推荐
02-25 17:58
吉首大学张家界学院 Python
最喜欢秋天的火龙果很...:第一份工作一定要往大的去,工资低点没事。后面换工作会更好找,即使你去小公司,你也不可能不会换工作的。所以找大的去 点赞 评论 收藏
分享
字节跳动公司福利 1383人发布
查看15道真题和解析