0
再见strlen函数
source link: https://blog.51cto.com/u_15740457/5753495
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
再见strlen函数
精选 原创功能:计算字符串长度。
计算第一种常量字符串,直接默认后面以\0结尾,输出结果是6;但第二种对数组的字符串进行计算,输出结果却是随机值。
原因:这两种计算方法没有区别,但是数组,后面没有默认\0的出现,所以一直寻找,生成随机值。
返回类型:无符号整型
此时输出结果为hehe;因为3-6本应该是-3,是负数,但两个无符号整型相减的结果仍然是无符号整型,所以输出结果仍为正>0
在网上查询到strlen的返回类型size_t==unsigned int!!!
- 赞
- 收藏
- 评论
- 分享
- 举报
上一篇:C语言找画笔(全网最详)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK