Hi Aaron, On Wed, Aug 14, 2024 at 01:59:58PM GMT, Ballman, Aaron wrote: > > Why would you be looping? lengthof only addresses the outer dimension > > sizeof would need a loop, no ? > > Due to poor reading comprehension, I missed in the paper that lengthof > works on the outer dimension. 😉 I think having a way to get the > flattened size of a multidimensional array is a useful feature.
As long as you know the type of the inner-most element, you can do it. This excludes auto, but I think you usually know this. double x[4][5][6][7]; size_t n = sizeof(x) / sizeof(double); This hard-codes 'double', but should be good enough usually. Cheers, Alex -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature