jeudi 25 octobre 2018

check if element in 2D arrays in if statement is equal to 1 or 0 - C

I am new to C and have look everywhere over internet for an answer to this questions.

I would like to check in this if statement whether the element that is stored inside world[i][j] is equal to one and if so, change its value to 0. I have written this but do not seem to get the desired result. Does anyone know how you would use an array in this case within an if statement?

Thanks!

        for (i=0, i<20, i++){
           for(j=0, j<20, j++) { 
             if (world[i][j]==1) {
                world[i][j] = 0;
             }
           }
         }

Aucun commentaire:

Enregistrer un commentaire