There is no need for the second if check. There can only be one of two things: It's playerA's turn, or it's playerB's turn. There is no other possibility. Therefore, there is no need for the second check.
Code:
void SwitchTurns()
{
if (p1.myturn == TRUE)
{
p1.myturn = FALSE;
p2.myturn = TRUE;
}
else
{
p1.myturn = TRUE;
p2.myturn = FALSE;
}
}
However, I doubt this is where your problem lies. The real problem is likely where you check to see who's turn it is.
Code:
void DropRow(int row)
{
char piece;
/**
*** No need for second 'if'.
**/
piece = p1.myturn ? 'Q' : 'X';
//check drop and win criteria
//not done yet
//Big stuff--------------
if (putvert < 0)
{
msg = 1;
putvert = 7;
StartGame();
}
if (board[putvert][row-1] != 'O')
{
putvert--;
DropRow(row);
}
/**
*** You never check 'row' for
*** validity. This could be your
*** problem.
**/
if (board[putvert][row-1] == 'O')
{
board[putvert][row-1] = piece;
}
Personally, I wouldn't have the drop function handle my side switching. I'd basicly do something like:
Code:
while( !game_over )
{
ShowBoard( );
row = PromptRow( p1.myturn ? p1 : p2 );
Drop( row );
game_over = CheckWin( );
SwitchTurns( );
}
CongradulateWinner( );
Quzah.