当前位置:网站首页>arduino获取数组的长度
arduino获取数组的长度
2022-07-06 09:16:00 【一入极客深似海】
假设,当前有这么一个数组
String str[]={
"ddd","ddd","dsgsd","fdsf","oooo"};
使用 sizeof() 函数
sizeof(str)是获取数组的总字节长度,
sizeof(str[0])是获取数组中一位的字节长度。
用总字节长度/一位字节长度。
得出的结果就是。数组的长度。
示例代码
String str[5]={
"ddd","ddd","dsgsd","fdsf","oooo"};
int num;
void setup() {
Serial.begin(9600);
num=sizeof(str) /sizeof(str[0]);
Serial.print("数组长度:");
Serial.print(num);
}
void loop() {
}
边栏推荐
- MySQL主从复制的原理以及实现
- FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation
- 2019腾讯暑期实习生正式笔试
- [BSidesCF_2020]Had_ a_ bad_ day
- Encodermappreduce notes
- [Bluebridge cup 2020 preliminary] horizontal segmentation
- 第4阶段 Mysql数据库
- PyTorch四种常用优化器测试
- 【yarn】Yarn container 日志清理
- MySQL realizes read-write separation
猜你喜欢
随机推荐
Pytorch实现简单线性回归Demo
Internet protocol details
IOT system framework learning
Solution of deleting path variable by mistake
电商数据分析--用户行为分析
2019 Tencent summer intern formal written examination
Mysql的索引实现之B树和B+树
树莓派 轻触开关 按键使用
Stage 4 MySQL database
Detailed explanation of nodejs
TypeScript
MySQL主从复制的原理以及实现
wangeditor富文本组件-复制可用
[Blue Bridge Cup 2017 preliminary] grid division
Contiki源码+原理+功能+编程+移植+驱动+网络(转)
机器学习--决策树(sklearn)
R & D thinking 01 ----- classic of embedded intelligent product development process
RT-Thread的main线程“卡死”的一种可能原因及解决方案
FreeRTOS 任务函数里面的死循环
分布式節點免密登錄








