Hi guys . How do i measure the length of an array ? Better to say : how do i pass every element from array? i found with begin() , end(), etc but doesnt work. Please help.
This will give absurd results if an inadvertent array-to-pointer decay has taken place.
And for anybody else who is interested to know a bit more about array-to-pointer decay ...
https://stackoverflow.com/questions/1461432/what-is-array-decaying
what I have always pondered about this question is not how to do it but why you don't know the size of the array ... which had to be available at compile time. If you need the size, pass it around or use a vector or bundle up a struct with size attached or something. You are trying to compute (with a slightly risky approach) .. a known compile time constant.
You can even cheat and put the size in the first location of the array (pascal style), either as data (POD types) or as raw bytes dumped in (a little kludgy for class types, and a dubious approach, but its been done).