int delete_user(const char *name, User **user_ptr_del) {
    User *leaver = find_user(name, *user_ptr_del); //The user we want to delete
    User *curr = *user_ptr_del; //for traversal 
    if(leaver == NULL || curr == NULL){
        return 1;
    }
    if(curr == leaver){
        *user_ptr_del = curr->next;
    }
    else if(curr != leaver){
        int j = 0;
        for(int i = 0; i<10; i++){
            if(curr->next->friends[i] != leaver){   
                curr->next->friends[j] = curr->next->friends[i];
                j++;               
            }
        }
        if(j == 8){
            curr->friends[9] = NULL;
        }
    }
    
    while(curr->next != NULL){
        if(curr->next == leaver){
            User *a = curr->next;
            free(a);
            curr->next = curr->next->next;
        }
        else{
            int j = 0;
            for(int i = 0; i < 10; i++){
                if(curr->next->friends[i] != leaver){   
                    curr->next->friends[j] = curr->next->friends[i];
                    j++;               
                }
                }
            if(j == 8){
                curr->next->friends[9] = NULL;
            }
        }
        curr = curr->next;
    }
    return 0;   
}

help remove segmentation fault