Stupid C++ Tricks: A better sizeof_array()
January 23, 2011
The tried-and-true C way to determine the length of an array is this: #define sizeof_array(x) (sizeof(x) / sizeof(x[0])) As H. L. Mencken put it, “there is always a well-known solution to every human problem — neat, plausible, and wrong.” That is certainly the case with this approach. It’s short, to the point, very easy to [...]
6