I have written a function to place mines. I need 'X' to be in array position [0][0] I cannot randomize so it does not overlap the mines b/c I can have only four mines in a [4][5] array.
The problem I am having so that it checks to see if it is not already occupied and something with the 2nd if statement
void placeMines(char mineField[][5])
{
int z;
for(z = 0; z <4; z++)
{
int a, b;
a = rand() % 4;
b = rand() % 5;
if(a != 0 && b != 0)
{
a = rand() % 4;
b = rand() % 5;
}
mineField[a][b] = 'M';
if(mineField[a][b] == 'M')
{
a = rand() % 4;
b = rand() % 5;
mineField[a][b] = 'M';
}
}
}