please help me with this..
(this s the function)- i don't know how to construct a code to test if array integer is empty using bool..pls help me..

(this s the function)- pls also include the main.. thanks

bool isArrayIntEmpty(int *numbers)

Recommended Answers

All 8 Replies

It's not possible to determine if the array is empty or not without knowing the array size. Even then the only way to tell if the array is empty is if the array size is 0.

Maybe if the pointer to the base of the array is NULL, then it's not an array at all. But it could be, and it's definitely empty.

commented: good point :) +17

It's not possible to determine if the array is empty or not without knowing the array size. Even then the only way to tell if the array is empty is if the array size is 0.

You assign the array size to an int variable, then return "true" if that variable is equal to zero..

You assign the array size to an int variable, then return "true" if that variable is equal to zero..

You have to pass the array size as another parameter. The function prototype he posted is incomplete.

This question is so ambiguous since it doesn't define what an empty array should constitute. One can only guess, smh

Layout:

bool isArrayIntEmpty(int *numbers,int arraysize){
//Assign the size of the array to arraysize
if(arraysize == 0)
return true;
else
return false;
}

That should help??

Maybe if the pointer to the base of the array is NULL, then it's not an array at all.

But Annana...

int *buffer = NULL;
//buffer is now empty.
buffer = new int[128];
//buffer now is an array of 128 integers.
delete [] buffer;
buffer = NULL;
//buffer is now empty.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.