#include
#include //调用库函数strlen,
//求字符串的有效长度
int mystrlen(const char *src)
{
int count=0;
while(*src!=0)
{
count ++;
src++;
}
return count;
}
int main()
{
char str1[100] = "abcdef";
char *str2 = "abcdef";
char str3[] = "abcdef";
char str4[100] = "abcde\0fgh";
char str5[] = "abcde\0fgh";
char *str6 = "abcde\0fgh";
printf("%d,%d\n",sizeof(str1),strlen(str1));//100,6
printf("%d,%d\n",sizeof(str2),strlen(str2));//4,6
printf("%d,%d\n",sizeof(str2),mystrlen(str2));//4,6
printf("%d,%d\n",sizeof(str3),strlen(str3));//7,6
printf("%d,%d\n",sizeof(str4),strlen(str4));//100,5
printf("%d,%d\n",sizeof(str5),strlen(str5));//10,5
printf("%d,%d\n",sizeof(str6),strlen(str6));//4,5
printf("%d\n",strlen("*&^%43@! ][")); //11
printf("%d\n",mystrlen("*&^%43@! ][")); //11
printf("%d\n",mystrlen("56123dhkj")); //9
return 0;
}