samedi 18 novembre 2017

Comparing Two Dimensional Arrays in C without strcmp

char status = 'f';
char arr1[11][11];
char arr2[11][11];
......

do{
......
  for(int x=0; x<11; x++){
  for(int y=0; y<11; y++){
        if(temp[x][y]!=store[x][y]){
            status='f';
            }
        else{
            status='t';
            }
        }}
}
while(status != 'f');
......

The above is my code for a do-while loop.

From my knowledge, when the condition within while is true, the program should run again from do.

Assuming my understanding is correct, when temp[x][y] does not equal to store[x][y], the program should let status = 'f' and the loop continues. Once temp and store are equal, status = 't' and the loop will end.

My problem now is that while I am able to proc the loop, the loop wont end even when temp and store are equal. What am I doing wrong?

Thank you!

Aucun commentaire:

Enregistrer un commentaire