Getting the size of an array with any datatype

This tip submitted by Saddam Abu Ghaida on 2012-10-26 09:00:32. It has been viewed 2585 times.
Rating of 7.4 with 5 votes

its pretty straight forward approach which happens by dividing the length of an array of anytype to the size of its field.

#define NUM_OF(x) (sizeof (x) / sizeof (*x))

More tips

Help your fellow programmers! Add a tip!