Couple of things....
1) your arrays/indexes are not in sync. Your board is "char[7,12]", meaning the indexes go from 0..6 and 0..11, respectively. Look at some of your loops - you have them checking for "j<13", meaning "j" can go up to 12, which is outside the bounds of the array. I was getting error messages when I ran the code about the stack being corrupt.
2) Your "for" loop for drawing the dashes (on your odd lines) was inside the "if" statement checking for the even lines. Once I properly indented the code it jumped right out at me. Like this:
void setgameboard(char board[7][12])
{
int i,j,k;
for (i=0;i<7;i++)
{//row loop
if (i==0||i==2||i==4||i==6)
{ //if row isnt barrier
for (j=0;j<13;j++)
{//start row that isnt barrier
if(j==0||j==4||j==8||j==12)
{
board [i][j]='O';
} //is open space for token
if(j==1||j==3||j==5||j==7||j==9||j==11)
{
board[i][j]=' ';
}//is space
if(j==2||j==6||j==10)
{
board[i][j]='|';
}//is divider
} //close if row isnt barrier loop
if (i==1||i==3|| i==5)
{
for (k=0;k<13;k++)
{
board[i][k]='-';
}
} //if row is barrier
} //close column loop
}//close row loop
} Lines 23-29 should be moved below line 30, to be out of the "if" statement on line 6.
mcriscolo
Posting Whiz in Training
218 posts since Apr 2008
Reputation Points: 57
Solved Threads: 64