hello guys, i was wondering if anybody can tell me what am i doing wrong with this code. the purpose of this code is to simulate the connect four game and i am supposed to use arrays. ok my problem is this. the game asks the user to select a column. and when it is selected, it drops an 'X' all the way to the bottom. ok i have that done. so my problem is that whenever i select the same column, the 'X' does not stack on top of the previous 'X' instead it just overwrites it and thats it. so thats is what i would like to do. for the 'X's to stack up. here is my code, i would really appriciate it. thanx.
------------------------------------------------------------------------------------
#include <stdio.h>
#define N 7
#define F 4
int main (void)
{
char board[N][N];
int i,j,sel;
printf("Welcome to Connect %d\n",F);
for(i=0;i<N;i++)
for(j=0;j<N;j++)
board[i][j]='.';
do
{
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
printf("( %c )",board[i][j]);
printf("\n\n");
}
printf("select a column: ");scanf("%d",&sel);
for ( i = N-1 ; i >= 0 ; i++ )
{
if (board[i][sel-1] != '.') break;
else if(board[i][sel-1]='X') \\im guessin that my problem is
board[i--][sel-1]='X'; \\on these three lines
else
board[i][sel-1]='X'; \\...
}
}while(sel>=1 && sel<=N);
return 0;
}