当前位置:网站首页>The difference between strlen and sizeof
The difference between strlen and sizeof
2022-07-27 05:09:00 【Code loving students】
Catalog
strlen and sizeof The difference between :
1. What is? sizeof
sizeof It's a Operator , Its value has been calculated during compilation , Its parameters can be arrays 、 type 、 object 、 Functions, etc .
function : Calculate the maximum bytes of space occupied by this parameter
Because computation occurs during compilation , therefore sizeof Only non dynamic objects can be calculated ,sizeof The return value of is independent of the content of the passed in parameter , And its return value is size_t type , That is to say unsigned int type .
2. What is? strlen
strlen It's a function , Its value is calculated at runtime ,strlen The parameter of must be char* type
function : Calculate encounter '\0' Number of all previous characters
strlen and sizeof The difference between :
- sizeof It's the operator You don't need to add parentheses , and strlen Is the function Parentheses must be added

- sizeof You can take the type as the parameter , and strlen Can only be char* As a parameter
- Array as sizeof Parameters of are not degraded , And as a strlen Will degenerate into char* The pointer
- strlen The size of is calculated at runtime , and sizeof The size of is calculated at compile time
- sizeof It calculates the space occupied by the whole parameter , and strlen The calculation is to meet '\0' Number of all previous characters

边栏推荐
- 报错:cannot read poperties of undefined(reading ‘then‘)
- Test basis 5
- MySQL下载安装 & 完美卸载
- When using Photoshop, the prompt "script error -50 general Photoshop error appears“
- 【搜索】—— 多源BFS + 最小步数模型
- [search] connectivity model of DFS + search order
- Invert a Binary Tree
- Hiding skills of Photoshop clipping tool
- Typescript details
- 树莓派输出PWM波驱动舵机
猜你喜欢

pyside2____1.安装和案列

How to test the payment process?

How to copy Photoshop layers to other documents

Web框架介绍

kali系统arp介绍(断网嗅探密码抓包)

精选用户故事|洞态在聚水潭的误报率几乎为0,如何做到?

What if Photoshop prompts that the temporary storage disk is full? How to solve the problem that PS temporary storage disk is full?

Another skill is to earn 30000 yuan a month+

【搜索】双向广搜 + A*

项目对接支付宝支付,内网穿透实现监听支付宝的支付成功异步回调通知
随机推荐
Deep Qt5 signal slot new syntax
Complete Binary Tree
"Photoshop2021 introductory tutorial" flatten "perspective images
Knowledge about hash index and b+ tree
static和final关键字 学习 demo练习
Event Summary - common summary
OFDM 十六讲 2- OFDM and the DFT
对话框数据传递
【搜索】DFS之连通性模型 + 搜索顺序
Why is count (*) slow
Network protocol details: IP
网络协议详解:IP
会议OA之我的审批
Web框架介绍
Could not autowire.No beans of ‘userMapper‘ type found.
【无标题】按照一定的条件,对 i 进行循环累加。条件通常为循环数组的长度,当超过长度就停止循环。因为对象无法判断长度,所以通常搭配 Object.keys() 使用。\nforEach 一般认为是 普
Test basis 5
Install pyGame
支付流程如何测试?
How to test the payment process?