What does #define array_size(a) sizeof(a)/size(a[0]) mean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What does #define array_size(a) sizeof(a)/size(a[0]) mean?

17th Mar 2017, 6:34 AM
Anurag Lahon
Anurag Lahon - avatar
2 Answers
+ 2
sizeof (a) gives you a size in bytes of full array. sizeof (a[0]) gives you the size in bytes of its first item. And to find out the size of array (how many items) you use the division operator. This is what macro does. It is used to find out the size of array in compile time.
17th Mar 2017, 6:42 AM
soman
0
Hey thnx man
17th Mar 2017, 6:44 AM
Anurag Lahon
Anurag Lahon - avatar