This will not work; adding an integer to a pointer is pointer arithmetic, and the compiler cannot carry out pointer arithmetic if the size of the object pointed to is unknown. If you want to do this pointer arithmetic, you cannot have a void array.
I would suggest you drop arrays and move to a proper C++ container type.
This CAN'T be the whole code, I don't see your function shouldDeleteItem(...) declared anywhere in this, by the way you don't need to call it twice like that.
Why are you decrementing itemsCount AND incrementing 'i' and comparing them through every intereation?
I'm sure I'll come up with a few more questions.
EDIT: This:
1 2 3 4 5 6 7 8 9
for(int i=0; i<itemsCount; i++)
{
if(shouldDeleteItem(array+i*itemSize))
{
itemsCount--;
for(int j=i; j<itemsCount; j++)// <- A. RIGHT HERE
*(array+j*itemSize) = *(array+(j+1)*itemSize); //<- See B
i--;
//... More Code
A.)Will work but it is awkward to read, please don't do stuff like that.
B.) This is an issue, what are you trying to accomplish with this line of code?
I want to fill the gaps in the array. shouldDeleteItem(..) is pointer to function isOdd. The real question here is how i can pass to the elements of void array
You already ARE passing the elements of void array. You dynamically allocate them in your Main function (which should not be void by the way) and you pass the pointer on to your deleteItems(...) fucntion just fine. What you need to do is cast them to real types like rocketboy9000 said. Something like this:
There are other issues that will prevent this from compiling and I was trying to get ahead of those for you with my questions. And yeah I missed the part where shouldDeleteItem(...) is a pointer, that's an interesting way of doing it.
Yeah I was playing around with his code on my own and I tried int first, so that's what got copy pasted. You clearly state what he should so so hopefully he caught that.
EDIT: @ OP you mean you want to intentionally overrun the void array? or do you mean you want to skip it?