C – getting the length of an array using Macros

hello there

How to know the length of any array without using the conventional approaches such as strlen,wcslen .. etc, or looping through the array and increase the counter.

So the way to do it is pretty straight forward which is by  dividing the length of an array of anytype to the size of its field.

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

 

 

Posted in Cryptography, Programming, System Administartion, Technology and tagged , , , , . Bookmark the permalink. RSS feed for this post. Leave a trackback.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Swedish Greys - a WordPress theme from Nordic Themepark.