strlen()和sizeof()
来源:互联网 发布:大连理工大学网络教育 编辑:程序博客网 时间:2024/06/05 08:03
strlen()是函数,sizeof()是C语言的运算符。
char str[]="hello";
char *p=str;
sizeof(str)为6.sizeof表示的是所占空间的大小,包括字符串结束标志符‘\0’。
strlen(str)为5.只是求出字符串的个数,故不包括字符串结束符。
sizeof(p)为4(32位编译器时,64位时为8),p是指针变量本身,相当于sizeof(char*)
sizeof(p*)为1,p所指向的变量,p指向的变量是char型的,相当于sizeof(char)
strlen(p)为5,strlen是c库函数,用来返回字符串长度,不计算字符串末尾‘\0’.strlen接收的参数必须是字符串(字符串的特点是以‘\0’结尾)
0 0
- sizeof和strlen()
- 关于sizeof 和strlen
- sizeof 和 strlen区别
- strlen 和sizeof
- sizeof 和strlen
- strlen和sizeof
- strlen和sizeof
- sizeof 和strlen
- sizeof和strlen
- sizeof和strlen
- sizeof 和 strlen
- sizeof和strlen
- strlen和sizeof
- sizeof 和 strlen()
- sizeof和strlen
- sizeof和strlen
- sizeof和strlen区别
- 浅析sizeof和strlen
- C++字符串的输入函数之get()和getline()
- oracle SQL_EXEC_ID分析
- spring表达式语言spel
- 框架编写之聊天框架认识(五)
- 随便写写的java笔记(9)
- strlen()和sizeof()
- poj 1988 Cube Stacking
- bestcoder #72 DIV2 Clarke and MST 最大按位与的生成树
- App上架可能会遇到的事情以及解决方案
- mvc路由htaccess,基本是apache服务,php命名空间
- Nginx学习笔记——安装起步
- Stanford 机器学习 Week3 作业 Logistic Regression
- Office Web Apps安装部署
- Spring核心组件