Click to See Complete Forum and Search --> : length of int


sreeram_r
June 15th, 2001, 03:21 AM
I'M A NEW PROGRAMMER IN C++.I WANT TO KNOW HOW TO FIND THE LENGTH OF A INTEGER ARRAY IN C++..
THANK U..

Harayasu Onagi
August 10th, 2001, 05:17 PM
Hmm. You're at the wrong forum my friend.

But well, I assume you have defined an array like this:

int array [NR_OF_ELEMENTS];

The size of an int can be calculated using sizeof () operator:

int_size = sizeof (int);

And then the size of the array can be calculated like this:

array_size = int_size * NR_OF_ELEMENTS;

Andreas Masur
August 12th, 2001, 04:45 AM
Well, the short form would be...

int array[NR_OF_ELEMENTS];

int array_size = sizeof(array);




Ciao, Andreas

"Software is like sex, it's better when it's free." - Linus Torvalds