当前位置:网站首页>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

边栏推荐
猜你喜欢
![[search] connectivity model of DFS + search order](/img/67/40444e53621371b1c8b47f22ebc956.png)
[search] connectivity model of DFS + search order

C language address book management system (linked list, segmented storage of mobile phone numbers, TXT file access, complete source code)

2022 T2i text generated image Chinese Journal Paper quick view-1 (ecagan: text generated image method based on channel attention mechanism +cae-gan: text generated image technology based on transforme

Typescript details
![[search] - multi source BFS + minimum step model](/img/42/11b5b89153ab48d837707988752268.png)
[search] - multi source BFS + minimum step model

34. 分析flexible.js

树莓派rtmp推流本地摄像头图像

STM32 Hal serial port (uart/usart) debugging experience (I) -- basic knowledge of serial port communication +hal library code understanding

File dialog box

The execution process of a select statement in MySQL
随机推荐
节流函数的demo——正则表达式匹配
Three paradigms, constraints, some keyword differences,
测试基础5
"Photoshop2021 introductory tutorial" flatten "perspective images
Jmeter 界面如何汉化?
树莓派rtmp推流本地摄像头图像
34. 分析flexible.js
[error reporting]: cannot read properties of undefined (reading 'prototype')
Inspiration from "flying man" Jordan! Another "arena" opened by O'Neill
[error reporting] cannot read property 'parsecomponent' of undefined
写代码涉及到的斜杠/和反斜杠\
What if Photoshop prompts that the temporary storage disk is full? How to solve the problem that PS temporary storage disk is full?
Svn usage details
The project connects with Alipay payment, and the intranet penetration realizes the monitoring of asynchronous callback notification of successful payment of Alipay
STM32_ HAL_ SUMMARY_ NOTE
2、 MySQL advanced
Sunset red warm tone tinting filter LUTS preset sunset LUTS 1
Complete Binary Tree
【Acwing】第61场周赛 题解
【牛客讨论区】第七章:构建安全高效的企业服务