Help with Tic Tac Toe program

Dec 1, 2012 at 10:37pm
void  checkMark(char array, int userInput){
    
    int c=1;
    for(int i=0;i<3;i++){     
        for(int j=0;j<3;j++){
            if(userInput==c){
                array[i][j]='X';    //error here
            }
        c++;
        }
    }
}


I am making a tic tac toe game. This function is to switch out the number with an 'X' in the array, but it keeps giving me an error to do with the subscripts with the array.

In function `void checkMark(char*, int)':
invalid types `char[int]' for array subscript
[Build Error] [main.o] Error 1

Can I not use i and j as the subscripts in a function? It works perfectly fine if I put it in the main code.
Last edited on Dec 1, 2012 at 10:38pm
Dec 1, 2012 at 11:55pm
Anyone?? I really need help on this.
Dec 2, 2012 at 12:01am
array is of type char. It is not an array.

1
2
3
void checkMark(char array[][3], int userInput) {
// ...
}
Topic archived. No new replies allowed.