I have created a vector storing floats. I want to 'shuffle' the array so that elements are swapped. I do this using the function below.
1 2 3 4 5 6 7 8 9 10
void shuffleArray()
{
int a = 5;
for (int c = 8; c > 2; c--) {
//swap(bodyPos[c], bodyPos[a]);
float temp = bodyPos.at(a);
bodyPos[c] = temp;
a--;
}
}
the idea is that for the vector of length 9, the 9th element will contain data from the 6th, the 8th data from the 5th, the 7th data from the 4th etc.
However, even though viewing state of variable when the program is run (and even printouts of the variable) suggest it has swapped the elements data... In reality when I use the data it doesn't work and is usually 0 in spite of whatever was there.
I really could do with a heads up on where I'm going wrong!