possible to remove element from middle of array?

hello,

in my array availableLights, i am storing the pin numbers of LEDs that are off (these pin numbers are not necessarily in sequence).
then i pick one of these at random and turn it on.
i think i should be removing the value of the LED i just turned on.
can i iterate through the array and remove the value of the pin i just turned on? in the code below, i’m replacing it with a null character, but will that just cut off the array at that point? what if i have values further on in the array that i still want to access?

//let’s say that i turned on an LED connected to pin 6:

whichLight = 6;

//now i want to remove that value from my array,
//because it’s no longer “available” to be turned on:

for (int i = 0; i < numOff; i++) {
if (availableLights == whichLight) { *
_ availableLights = ‘\0’;_
_
}_
_
}*_
thanks for your help,
aya.

I'm not sure if using the null terminator like that would truncate the array, but why not just set the value to zero instead?

Using a bit field would be the most efficient use of memory.

i'm replacing it with a null character, but will that just cut off the array at that point?

A null character will terminate a string stored in an array. It does not truncate the array (or do anything else to the amount of memory allocated for the array in question).

The null character is simply a binary zero the size of a character.

For your array, this is exactly the same as availableLights[i] = (char) 0; which is effectively the same as availableLights[i] = 0;

-j