当前位置:网站首页>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 .
边栏推荐
- 【sylar】框架篇-Chapter11-Socket 模块
- [record of question brushing] 9. Number of palindromes
- About me writing a custom cell
- 23 openwrt switch VLAN configuration
- Campus stray cat information recording and sharing applet source code
- Idea start project MVN command terminal cannot recognize "MVN" item as cmdlet
- RN interface jump description
- 重要的 SQL Server 函数 - 其他函数
- Blooming old trees -- quickly build a map bed application with imageprocessor
- [Sylar] framework Chapter 6 collaborative scheduling module
猜你喜欢

Pyqt based grouping tool

重要的 SQL Server 函数 - 其他函数

VAE generation model (with VAE implementation MNIST code)

Mac installs mysql5.7 through brew

There are so many ways to view the web source code! Do you know?

Internet of things industrial serial port to WiFi module wireless routing WiFi module selection

校园流浪猫信息记录和分享的小程序源码

Jupyter Notebook安装代码提示功能

Reading the paper "learning span level interactions for aspect sentimental triple extraction"

Introduction to this pointer
随机推荐
25 openwrt guest network add
【sylar】框架篇-Chapter7-IO 协程调度模块
Docking with Hang Seng express ― dolphin DB NSQ plug-in tutorial
【牛客】求1+2+3+...+n
Niuke, convert string to integer
CMake使用基础汇总
Power consumption: leakage power
[Sylar] framework -chapter20- daemon module
Select sorting method
空间复杂度计算超全整理!!(一起手撕复杂度计算
Information system project manager (2022) - key content: Project Portfolio Management (19)
Go structure
[Sylar] framework Chapter 8 timer module
Simple summary of Modbus Protocol
[Niuke] find 1+2+3+... +n
Important SQL server functions - other functions
Reading of seq2path: generating sentimental tuples as paths of a tree
[Sylar] framework -chapter12 bytearray module
CMake使用基础汇总
[mathematical modeling] Based on MATLAB seismic exploration Marmousi model [including Matlab source code, 1977]