samedi 12 juin 2021

How to perform IF statment on a 2D array stored char rather than the [posX] [posY] vaule

Have a few if statements and I need them to be activated by a char's value stored in an array, not off the array's positional co-ordinate value.

Debugging has indicated I've failed to specify the array's char value.

In summary -- Code steps though fine and the else statement works. I just can't work out how to write the code to look for the stored char in the X & Y position so it can carry out the IF statement.

Currently is correctly skipping the IF statement.


void function(char source[SIZE_X][SIZE_Y], char input, int* posX, int* posY, int counter) {


    if (input == 'A') {
        printf("XXXX\n");

        if (source[*posX][*posY] == 'B') {
            printf("XXXX\n\n");
            (*posX) = *posX + 0;
        }
    
        else (*posX) = *posX + 1;
    }

Aucun commentaire:

Enregistrer un commentaire