Chess 960 position generator

Thanks for this info, I'll declare the size of those arrays.

I'm having trouble working out where to put the queen. I have a variable 'queen' that would be 0 to 6, and I have to put the Q into the index of the array that corresponds to the first open index.

So if the 'queen is 4', and the array is {B, B, 0, 0, 0, 0, 0, 0}, I need to put Q at index 6 like { B, B, 0, 0, 0, 0, Q, 0}.

So do I iterate over the array and count both the index count, and the 0-count?

This works for the 0th open index:

if (queen == 0){
    for ( int i = 0; i < 8; i++ ){
        if (back_rank[i] == '0') {
            current_index = i;
            break;
        }
   } 
back_rank[current_index] = 'Q';

But I'm having a hard time figuring out how to count the index, and the open squares (represented by '0'), when it is more than 0.

Thanks for any help.

Jimmy