int delete_user(const char *name, User **user_ptr_del) {

    // case 1: user is at start of list

    // case 2: user at middle of list

    // case 3: user at end of list

    // case 4: user does not exist

    User *user = find_user(name, *user_ptr_del);

    if (user == NULL) {
        return 1;
    }

    // loop through user's friends, for each friend, loop through their friends and remove the user friend

    // THIS PART DOESN'T WORK PROPERLY: FIX LOGIC
    // the while loop is not properly checking if the current user is the user to be deleted.
    for (int i = 0; i < MAX_FRIENDS; i++) {
        if (user->friends[i] != NULL) {
            User *user2 = user->friends[i];
            for (int j = 0; j < MAX_FRIENDS; j++) {
                if (strcmp(user2->friends[j]->name, name) == 0){
                    user2->friends[j] = NULL;
                }
            }
        }
    }

    // don't forget to free the user

    // case 1: user at start of linked list
    if (user == *user_ptr_del) {
        *user_ptr_del = (*user_ptr_del)->next;
    }

    // case 2 and 3
    User *prev = NULL;
    User *curr = *user_ptr_del;
    while ((curr != NULL) && (strcmp(curr->name, name) != 0)) {
        prev = curr;
        curr = curr->next;
    }
    if (prev == NULL) {
        *user_ptr_del = curr->next;
    } else if ((strcmp(curr->name, name) == 0) && curr->next == NULL) {  // this means user is at the end of the list
        prev->next = NULL;
    } else if ((strcmp(curr->name, name) == 0)  && curr->next != NULL){ // this means that element is in middle of list?
        prev->next = curr->next;
    } else { // in the case user is not in list?
        return 1;
    }

    // case 3: the element is at the end of the list

    // free the posts
    Post *post = user->first_post;

    while (post != NULL) {
        free(post->date);
        free(post->contents);
        free(post);
        post = post->next;
    }

    free(user);

    return 0;
}
/*
 * From the list pointed to by *user_ptr_del, delete the user
 * with the given name.
 * Remove the deleted user from any lists of friends.
 *
 * Return:
 *   - 0 on success.
 *   - 1 if a user with this name does not exist.
 */