0
void imprimirTablero(char *tablero[7][7], int *posicionX, int *posicionY)
{
    int i, j;
    tablero[posicionX][posicionY] = 'R';
    for(i = 0; i < LEN(tablero); i++)
    {
        for(j = 0; j < LEN(tablero[0]); j++)
        {
            printf(tablero[i][j]);
        }
    }
}

this method change the char in positionX, positionY and print the new matrix of chars.... please someone help me

2 Answers 2

1

You're using a pointer to an integer as an array index for both posicionX and posicionY. You need to dereference those pointers:

tablero[*posicionX][*posicionY] = 'R';
Sign up to request clarification or add additional context in comments.

4 Comments

or more likely, change them to int instead of int pointers void imprimirTablero(char *tablero[7][7], int posicionX, int posicionY)
L. Scott Johnson gave a good advice: if there is no needs to changeposicionX and posicionY, they must be passed as simple int value (by value)
Right. Your advice was good and correct. And there was no "need" to do it without pointers. But it is more likely that the core mistake was using pointers in the first place, not just in the forgetting to dereference them.
@VolAnd: and note the assignment of a char to the char pointer on that same line: another indication that the programmer is just confused about the parameter specification format.
1

You're passing a 2D array of pointers, not chars, and two pointers to ints, not ints. I think you want:

void imprimirTablero(char tablero[7][7], int posicionX, int posicionY)

judging by

tablero[posicionX][posicionY] = 'R';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.