vendredi 18 janvier 2019

How do I check if there is an element in a Matrix?

I'm Trying to check in my matrix of dimension [10][10], which spots are available to store data (String) there and which are occupied.

The code basically goes through the whole matrix and checks every spot.

I have tried using the strlen and != NULL but everything just prints that the spot is free.

char[] parque[10][10];

parque[5][5]="f47ac10b-58cb-4372-a567-0e02b2c3d499,ANR";

for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
        if(parque[i][j] != "") {
            printf("The Spot [%d][%d] is taken",i,j);
        } else {
            printf("The Spot [%d][%d] is free",i,j);
        }
    }
}

Basically the spot [5][5] should print that it's taken, at least that's what I want it to do...

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire