//例子1
char *c="abcdef";
char d[]="abcdef";
char e[]={'a','b','c','d','e','f'};
printf("sizeof(c):%d\tstrlen(c):%d\n",sizeof(c),strlen(c));
printf("sizeof(d):%d\tstrlen(d):%d\n",sizeof(d),strlen(d));
printf("sizeof(e):%d\tstrlen(e):%d\n",sizeof(e),strlen(e));
输出结果是
4 6
7 6
6 14//例子2
char *str1="absde";
char str2[]="absde";
char str3[8]={'a',};
char ss[] = "0123456789";
结果:
sizeof(str1)=4
sizeof(str2)=6;
sizeof(str3)=8;
sizeof(ss)=11