当前位置:网站首页>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() {
}
边栏推荐
猜你喜欢
Variable star user module
Machine learning -- linear regression (sklearn)
电商数据分析--薪资预测(线性回归)
Stage 4 MySQL database
Linux Yum install MySQL
[Blue Bridge Cup 2017 preliminary] grid division
Connexion sans mot de passe du noeud distribué
分布式事务的实现方案
Wangeditor rich text reference and table usage
【CDH】CDH5.16 配置 yarn 任务集中分配设置不生效问题
随机推荐
[CDH] modify the default port 7180 of cloudera manager in cdh/cdp environment
锂电池基础知识
error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_ s instead
Pytorch-温度预测
JS array + array method reconstruction
Matlab learning and actual combat notes
关键字 inline (内联函数)用法解析【C语言】
2019腾讯暑期实习生正式笔试
R & D thinking 01 ----- classic of embedded intelligent product development process
STM32型号与Contex m对应关系
RT-Thread 线程的时间片轮询调度
4、安装部署Spark(Spark on Yarn模式)
2019 Tencent summer intern formal written examination
Machine learning -- linear regression (sklearn)
[yarn] CDP cluster yarn configuration capacity scheduler batch allocation
STM32 如何定位导致发生 hard fault 的代码段
ES6 let and const commands
List and set
ES6 promise object
【yarn】Yarn container 日志清理