Error Returning an Array

On the return line I get: error: invalid conversion from 'char (*)[8]' to 'char'

I've read about similar errors that had to do with pointers, but I don't understand.

A reading resource on the subject would be helpful too.

Thanks in advance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
char ready(char checkers[8][8]){
    int b;
    for (int a; a<=8;a++){
        if (a%2==0){
            b=0;
        }
        else {
            b=1;
        }
        for (b;b<=8;b+2){
                if (a<=2){
                    checkers[a][b]='r';
                }
                else if (a>=5){
                    checkers[a][b]='b';
                }
        }
    }
    return checkers;
};
Last edited on
Use code tags (look it up in the forum)
You define your function to return a char, but checkers is an 8x8 char array. You either need to return a char (one single value, such as checkers[0][0]), or change the return type from char to char[8][8]
Thanks for the tip on the code tags. But I'm afraid I don't understand how I would change the return type for it to return an array. A piece of example code might help me see how it works.
Why do you need to return the array if you are modifying the one given to you? When you change the array in the function it changes outside the function too, arrays are not passed by value.
@ L B
So this could be a void function and I don't have to have anything returned for the array data to be used outside the function?
Yes.
Topic archived. No new replies allowed.