0 votes
by (120 points)
Can an array have length 0?

1 Answer

0 votes
by (1.4k points)
When you use sizeof(array) / sizeof(array[0]) you will get the number of elements in the array. int arr[] = {1, 2, 3, 4, 5}; Is an array of 5 elements, each element (int) takes 2 bytes so the array size is 10 bytes. long arr[] = {1, 2, 3, 4, 5};Feb 8, 2018');})();(function(){window.jsl.dh('_mcWOYLe9CtCe0PEP1o-M2Ao43','
');})();(function(){window.jsl.dh('9','
One way\u200b to find the length of an array is to divide the size of the array by the size of each element (in bytes).

Related questions

0 votes
1 answer
asked Jul 14, 2021 by pointers (160 points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
...