Almighty Bus Error

Blog about computer science, code snippets and tips.

GitHub repository with examples here.
Currently a Computer Engineering student at FCT/UNL.
May 3, 2009 at 3:36pm
Tags: Snippet  C 

Comments (View)

Snippet.C: Getting the length of an array.

The following C macro gets the amount of memory the array uses and divides it by the size of the first position:

#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x)[0])

Credits go to meqif.