定义字符串数组
#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
请按任意键继续. . .
全部评论
相关推荐
编程界菜鸡:都一个月,就算是实习也会觉得不稳定
点赞 评论 收藏
分享