Here is a set of conditionals which moves a char in a vector, using the swap function, depending on certain variables:
if (m == 's')
{
if (currenti == 5)
{
swap(height[currenti][currentj], height[0][currentj]);
}
else if (height[currenti++][currentj] == 'T')
{
cout << "Game over!" << endl;
gameLive = 0;
}
else
{
swap(height[currenti][currentj], height[currenti++][currentj]);
}
}
For some reason the swap in the else part doesn't swap the two vector parts, even though it is called. (I put in a cout, in the else section, to check this). However, if I remove the other conditionals like this:
if (m == 's')
{
swap(height[currenti][currentj], height[currenti++][currentj]);
}
It works completely fine.
Does anyone know what is causing it to not work in the "else" format?