当前位置:网站首页>[C language] detailed explanation of C language to obtain array length
[C language] detailed explanation of C language to obtain array length
2022-06-28 06:43:00 【Embedded workplace】
1、 Use sizeof keyword
use sizeof You can get the number of bytes the data type or variable occupies in memory .
Again , use sizeof You can also get the number of bytes the entire array occupies in memory .
Because the type of each element in the array is the same , The number of bytes in memory is the same , So the total number of bytes divided by the number of bytes occupied by an element is the length of the array .
2、 Program instance
#include <stdio.h>
int main(){
// Define an array
int arr[30];
// Find array length
int n = sizeof(arr)/ sizeof(arr[0]);
printf(" The array length is : n=%d\n",n);
return 0;
}
边栏推荐
- Speech enhancement - spectrum mapping
- Paper recommendation: efficientnetv2 - get smaller models and faster training speed through NAS, scaling and fused mbconv
- extern “C“概述
- Yolov5 adds a small target detection layer
- 编译配置in文件
- Niubi 666, this project makes web page making as simple as building blocks
- fpm工具安装
- FPGA - 7 Series FPGA selectio -09- io of advanced logic resources_ FIFO
- Uni app wechat applet sharing function
- Students who do not understand the code can also send their own token. The current universal dividend model can be divided into BSC and any generation B
猜你喜欢

Unity packaging webgl uses IIS to solve the error

freeswitch设置最大呼叫时长

【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
![[online tutorial] official iptables tutorial -- learning notes 1](/img/b9/8f94caa46eb46dab581c713494f36d.png)
[online tutorial] official iptables tutorial -- learning notes 1

声网 VQA:将实时互动中未知的视频画质用户主观体验变可知

Techo Day 腾讯技术开放日,6月28日线上等你!

pytorch RNN 学习笔记

Last 29 days

Speech enhancement - spectrum mapping

AutoCAD C# 多段線小銳角檢測
随机推荐
AutoCAD C# 多段线自相交检测
FPM tool installation
普歌 -- 单例模式
职场IT老鸟的几点小习惯
Configure redis from 0
ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map
Linked list (I) - remove linked list elements
D3D11_ Chili_ Tutorial (3): design a bindable/drawable system
Create a gson object that formats the time zone. JSON parsing time formatting zoneddatetime
OpenGL API learning (2008) client server client server
Linked list (II) - Design linked list
Puge -- singleton mode
It will cost 700 yuan to realize this issue. Does anyone do it?
js正则表达式系统讲解(全面的总结)
[produced by Xinghai] operation and maintenance inspection collection
Techo Day 腾讯技术开放日,6月28日线上等你!
Wechat applet paging function, pull-down refresh function, direct dry goods
【星海出品】 运维巡检合集
Overview, implementation and use of CRC32
AutoCAD C polyline small acute angle detection