Calculate how many elements are in the array

An integer occupies 4 bytes of space; a character array has 1 byte of space

Calculating the size of the a array in C language isprintf("a数组的大小是%d\n",sizeof(a));

Calculating the space of an integer array in printf("一个整型数组的空间是%d\n",sizeof(int));
C language is the space of calculating a character array in C language"printf("一个字符型数组的空间是%d\n",sizeof(char));

Count the number of elements in an array in C language: the total size of the array / the size of a type
namely:sizeof(a) / sizeof(a[0])

Guess you like

Origin blog.csdn.net/zouchengzhi1021/article/details/111602440