# hello,
# Is there a way to implement a little function to return the size of an array
# (not a string)?
#
# Something like int size(int *array)
The language does not define any way of extracting the allocated size
from a pointer to the first (or other) element. While an implementation
might (for example if pointer are segregated to different pages based on
allocation size), the portable solutions are to pass the length around
with the pointer or use a sentinel vector element.
If the OP chooses to pass the length along with the pointer, I could
show him a _real_ efficient implementation of size() ...
-leor
P.S. Have I gauged this right, such that it would be perceived as
humorous rather than sarcastic? I didn't want to put a smiley there
and prejudice the verdict...
Leor Zolman
BD Software
(e-mail address removed)
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at
www.bdsoft.com/tools/stlfilt.html