本屌是小白,以后如果文章中有错误的地方,欢迎指正;谢谢各位大神浪费时间翻阅。
strlen计算字符串大小遇到'\0'结束;ziseof计算字符串内存空间大小包括'\0'在内;
#include<stdio.h>
#include<string.h>
int main(int argc, const char *argv[])
{
char s1[] = "hello kitty";
char s2[32] ="bye";
printf("%d\n",sizeof(s1));//12;
printf("%d\n",sizeof(s2));//32;
printf("%d\n",strlen(s1));//11;
printf("%d\n",strlen(s2));//3 ;
return 0;
}