当前位置:网站首页>Strlen introduction, and the difference between sizeof
Strlen introduction, and the difference between sizeof
2022-07-28 04:34:00 【Magic tea】
Catalog
3、 ... and : and sizeof Comparison
One : Definition
strlen function : This function calculates the number of characters in the string starting from the first character , Until an empty character is encountered '\0' until , Then return the length of the calculated number of characters , Include '\0'.
Two : give an example
int main()
{
char s[]=("123456789 ");// Notice that I typed an extra space here , Indicates that spaces are also valid characters
int ch = strlen(s);
cout << strlen(s) << endl;
return 0;
}![]()
This means that strlen Is the number of valid characters of the string returned .
3、 ... and : and sizeof Comparison
int main()
{
char s[]=("123456789 ");
int ch = strlen(s);
cout <<"strlen Length under :"<< strlen(s) << endl;
cout << "sizeof Length under :"<<sizeof(s) << endl;
return 0;
}
Comparison results :
sizeof The calculation will '\0' It's included , Is the string length +'\0'(+1),strlen Just calculate the string length .
边栏推荐
- Information system project manager (2022) - key content: Project Portfolio Management (19)
- How to upgrade a pair of 12.2 RAC(primary) and a pair of 12.2 RAC(dataguard) to 19c
- Object locking in relational database transactions
- About me writing a custom cell
- could only be written to 0 of the 1 minReplication nodes. There are 0 datanode(s) running and 0 node
- Information system project manager (2022) - key content: information system integrated testing and management, project management maturity model, quantitative project management (21)
- Introduction to this pointer
- Solana's "deceptive behavior": making mobile phones and opening stores
- 《KG-BERT: BERT for Knowledge Graph Completion》
- Slice slice
猜你喜欢

将数据库拿到的数据渲染到elementUI 中的table中去

Ma Yi, Shen Xiangyang, Cao Ying's latest AI overview is hot! It took 3 months to build, netizens: required papers

Introduction to this pointer

Virtual machine class loading mechanism

01-Node-Express系统框架搭建(express-generator)

Transformer landing | next vit realizes the real-time landing of industrial tensorrt, surpassing RESNET and cswin

Select sorting method

高数_第4章__曲线积分

Reading of seq2path: generating sentimental tuples as paths of a tree

DNS series (III): how to avoid DNS spoofing
随机推荐
【sylar】框架篇-Chapter12-ByteArray 模块
Important SQL server functions - date functions
【sylar】框架篇-Chapter15-Stream 模块
[yolov5 practice 5] traffic sign recognition system based on yolov5 -yolov5 integration pyqt5
重要的 SQL Server 函数 - 数字函数
Advanced architects, 16 common principles of microservice design and Governance
DNS series (III): how to avoid DNS spoofing
When import is introduced, sometimes there are braces, sometimes there are no braces. How should we understand this?
关系数据库事务中的对象锁定
25 openwrt guest network add
Shanghai Telecom released public computing services and signed the action plan of "Joint Innovation Center for intelligent computing applications" with Huawei and other partners
Information system project manager (2022) - key content: Project Procurement Management (12)
Docking with Hang Seng express ― dolphin DB NSQ plug-in tutorial
Bio annotation of emotion analysis aste triples extraction
VAE generation model (with VAE implementation MNIST code)
【sylar】框架篇-Chapter24-支持业务模块化
CMake使用基础汇总
10 more advanced open source command line tools
[Sylar] framework -chapter14 tcpserver module
What is the account opening process of qiniu business school? Is it safe?