I have an array of unsigned long long numbers. I initialize the first 12 elements. The array changes size throughout the programs runtime. How can I find out the length of the array.
I can't use sizeof(array)/sizeof(unsigned long long) since it doesn't work correctly in this case.
I tried using this loop:
count = 0;
while ( array[count] ) count++;
return count;
The problem with this method is that it still returns the wrong length.
Here is the basic rundown of the code.
unsigned long long *prime = (unsigned long long *)calloc(1000, sizeof(unsigned long long);
prime[0] = 3;
prime[1] = 5;
....
prime[11] = 41;
unsigned long long *ptrEmpty = &prime[12];
int sizeComp;
//User can change change the size of the array here to create a larger list of primes.//
for( i = 43, sizeComp = 12; sizeComp < length(prime); i += 2 ){
// Do stuff...
}
How can I find this length?