strlen和sizeof的区别

来源:互联网 发布:asp.net商城系统源码 编辑:程序博客网 时间:2024/05/29 03:26

本屌是小白,以后如果文章中有错误的地方,欢迎指正;谢谢各位大神浪费时间翻阅。

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;}


原创粉丝点击