Post: Array Size [C++]
03-19-2011, 03:09 AM #1
kiwimoosical
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({}); A lot of people ask me how to find the size of an array in C++, so here is what I tell them:

The size of the array (bytes) / the size of one element in the array.

Which people don't understand, so here is a little function for it:

    
template<typename type>
int arraySize(type* anArray)
{
int size = (sizeof(anArray) / sizeof(type));
return size;
}
03-19-2011, 06:50 AM #2
XDev
Banned
thanks man this helped me out
03-19-2011, 11:30 AM #3
kiwimoosical
Bounty hunter
Originally posted by XDev View Post
thanks man this helped me out


No problem

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo