char a[]={'a','b','c','d','e'};
int len=sizeof(a);
printf("len = %d\n",len); //输出5,直接得出数组长度
2,对于数组来说sizeof和strlen的区别
char b[20]="this is a string";
int len_b_sizeof=sizeof(b);
int len_b_strlen=strlen(b);
printf("len_b_sizeof = %d\n",len_b_sizeof);//输出20,sizeof输出的时b分配是的内存大小printf("len_b_strlen= %d\n",len_b_strlen);//输出16,strlen输出的时字符串的长度