Arghh passing 2D arrays to a func gives errors
Hi C people,
I'm trying to teach my self how to program in C and I'm generally new to programming. I've written some small programs with loops so far and now I'm trying to make a checkers game as my first real program in C.
I'm currently having trouble passing a two dimensional array to another function. I keep getting the error
"warning: assignment makes integer from pointer without cast"
???
Obviously I can't ignore this error, since when I fill up my 2D array with checkers pieces, I'm getting jibberish instead.
can someone see where I'm going wrong?
Btw I'm using context and cygwin.
Code:
#include <stdio.h>
#include <stdlib.h>
/*
A Simple checkers game
By Bryce M
ALG:
step 1 declarations
step 2 print checkers board
*/
void fillboard(char checkerboard[8][8])
{
int i=0,j=0;
for(i=0;i<8;i++){
for(j=0;j<8;j++){
if(i<3){
// populate enemy board
if(i%2 == 0){
if(j%2 == 0){
(checkerboard[i][j] = " ";
// blanks every even o,2,
}
if(j%2 ==1){
}
checkerboard[i][j]= "O";
//token on odd
}
if(i%2 == 1){
if(j%2 == 0){
checkerboard[i][j] = "O";
// blanks every even o,2,
}
if(j%2 ==1){
checkerboard[i][j]= " ";
//token on odd
}
}
}
if(i<5 && i>3)
{checkerboard[i][j] = " ";} //blanks in middle
if(i>4)
{
// populate user board
if(i%2 == 0){
if(j%2 == 0){
checkerboard[i][j] = " ";
// blanks every even o,2,
}
if(j%2 ==1){
}
checkerboard[i][j]= "X";
//token on odd
}
if(i%2 == 1){
if(j%2 == 0){
checkerboard[i][j] = "X";
// blanks every even o,2,
}
if(j%2 ==1){
checkerboard[i][j]= " ";
//token on odd
}
}
}// end i>4
}//end j
}//end i
}//end function
void drawboard(char checkerboard[8][8])
{
int i,j,n;
for(n=0; n<9; n++)
{
if(n == 0){printf(" ");}
else{printf(" %d",n);}
}
printf("\n");
//draw row
for(i=0; i<8; i++){
for(j=0;j<18;j++){
if(j ==0)
{ printf("%c",65+i);}
else if(j%2 == 1)
{ printf("|");}
else if(j%2 == 0)
{ printf("%c",checkerboard[i][j]);}
}
printf("\n");
}
}
int main (int argc, char *argv[])
{
char checkerboard[8][8];
printf("\nRunning Checkers game v1.0\nBy brcye M\n");
printf("Latest Rev 12/09/2009\n\n\n");
printf("******************************\n");
printf("** WELCOME TO CHECKERS IN C **\n");
printf("******************************\n\n");
fillboard(checkerboard);
drawboard(checkerboard);
return 0;
printf("\n");
}