Search code examples
cexc-bad-access

EXC BAD ACCESS TREAD in c


it gives me EXC_BAD_ACCESS (code=1, address=0xc) at the strcmp in the while (strcmp(parola, temp->next->parola) picture of the xcode debugging session

if (temp->next != NULL){
        if (strcmp(temp->next->parola, "\0") != 0 && strcmp(parola, "\0") != 0){
            while (strcmp(parola, temp->next->parola) != 0){
                if(temp->next != NULL){
                    if (strcmp(temp->next->parola, "\0") != 0 && strcmp(parola, "\0") != 0){
                        temp = temp->next;
                    } else {break;}
                } else {break;}
            }
        }
    }

Solution

  • if (temp->next != NULL){
        if (strcmp(temp->next->parola, "\0") != 0 && strcmp(parola, "\0") != 0){
            while (strcmp(parola, temp->next->parola) != 0){
                        if (strcmp(temp->next->parola, "\0") != 0 && strcmp(parola, "\0") != 0){
                            temp = temp->next;
                    if(temp->next != NULL){
                        } else {break;}
                    } else {break;}
                }
            }
    }