I get a fatal error when the following lines are run. foe is an array of objects (representing monsters in a game I'm making), nummonsters is the number of monsters in that array. When they are destroyed, I run this loop to remove the dead monsters (by swapping their position with the last one, and reducing the scope of the array).

Does the following look ok?

Code:
     for (int i=0; i<nummonsters; i++){
         if (foe[i]->hp<=0) {foe[i]=foe[nummonsters]; nummonsters--; return;}
     }
I have never used the 'foe[i]=foe[nummonsters]' thing before. Must I manually assign each variable :
Code:
foe[i]->a=foe[nummonsters->a;
foe[i]->b=foe[nummonsters->b;
foe[i]->c=foe[nummonsters->c;
etc.