This is my code.
void change_matrix(){
scanf ("%s %s", p1, p2);
int exists1, exists2, change1, change2;
exists1 = verify(p1);
exists2 = verify(p2);
if (exists1 == -1 && exists2 == -1)
printf("%s does not exist\n %s does not exist\n", p1, p2);
else{
if (exists1 == -1)
printf("%s does not exist\n", p1);
else {
if (exists2 == -1)
printf(""%s does not exist\n", p2);
else {
change1 = matrix[exists1][exists2];
printf("change made (%s,%s)%d\n", p1, p2, change1);}}}}
The problem is that if both exists1 and exists2 don't exist it ignores the fact that exist1 equals -1 and just says that exists2 does not exist. Why is that?
Aucun commentaire:
Enregistrer un commentaire