How to check array value at specific index

hello everyone, how can I check that value at specific index of an array is empty or not. for example

1
2
3
4
void storeAt( int index,int val)
{
   arr[index] = val //arr[] has been declared in class
}


I can put value only if arr[index] is empty, if already occupied I cannot add value. how can I check arr[index] is empty?
First of all you should define what means an element is empty.
element obviously cannot be empty. im talking about the array's index
Last edited on
Read one more what I wrote if you can not understand what I said.
If you meant to check whether an element is equal to some value when you can write

1
2
3
4
bool storeAt( int index,int val)
{
   return arr[index] == val;
}
Topic archived. No new replies allowed.