Wednesday, December 06, 2006

sizeof an Array in C++

Do not hestitate to use the below code. Just gives the size of an array in C++. :)
double array = {1.0,2.0,3.0,4.0,5.0};
int size = sizeof array / sizeof array[0];
Altough it is too long to write (just for taking the size) and hard to understand what is calculated, this code gives the result as 5.

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home