strlen 是求字符串长度的函数,它不包括字符串后面的‘\0’
sizeof 是计算任意类型对象所占字节的运算符,在计算字符串常量大小时包括后面的‘\0’
1、char str[] = "hello";
strlen(str) = 5
sizeof(str) = 62、int Array[] = {1,2,3,4,5,6,7,8,9};
sizeof(Array) = 36
3、char str[] = "hello";
char *p1 = str;
strlen(p1) = 5
sizeof(p1) = 4
4、char *p2 = "hello";
strlen(p2) = 5
sizeof(p2) = 4
5、char p3[] = {'h','e','l','l','o'};strlen(p3) = 随机值
sizeof(p3) = 5
6、char t[]="cskjdj300";
strlen(t) = 9
sizeof(t) = 10
7、char q[] = {'h','0','e','l','l','o'};
strlen(q) = 随机值
sizeof(q) = 6//注意这里是字符‘0’,而不是数字0或'\0'
8、char q1[] = {'h','\0','e','l'}; //或 char q1 = {'h',0,'e','l'}; strlen(q1) = 1
sizeof(q1) = 4
未完待续................................