void remove_friends(const char *name, User **ptr_users) {
    // Create a pointer to traverse the list of users
    User *curr = *ptr_users;

    // Traverse through the list of users
    while (curr != NULL) {
        // f_count stores the number of friends curr has
        // u_count stores 1 + the index the deleted user is found in the friendlist
        int f_count = 0;
        int u_count = 0;

        // Iterate through the friendslist of current user to obtain values of
        // f_count and u_count
        for (int i = 0; i < MAX_FRIENDS; i++) {
            if (curr->friends[i] != NULL) {
                f_count++;
                if (strcmp(curr->friends[i]->name, name) == 0) {
                    u_count = f_count;
                }
            }
        }

        // Remove the user from the friendlists
        // Check if user exists in the friendlist
        if (u_count != 0) {
            // Check if curr only has one friend
            if (f_count == 1) {
                curr->friends[0] = NULL;
            } else {
                // Shift every element in the friendlist after the the deleted user
                // to the left by 1
                for (int x = u_count - 1; x < f_count - 1; x++) {
                    curr->friends[x] = curr->friends[x + 1];
                }
                curr->friends[f_count - 1] = NULL;
            }
        }
        curr = curr->next;
    }
}
int delete_user(const char *name, User **user_ptr_del) {
    // Delete user from list

    // Create a variable to traverse the list
    User *curr = *user_ptr_del;
    // Create a variable to hold the deleted user
    User *temp = malloc(sizeof(User));

    // Check for empty users list
    if (*user_ptr_del == NULL) {
        return 1;
    }

    // If there is 1 element in the list
    if (curr->next == NULL) {
        if (strcmp(curr->name, name) == 0) {
            temp = curr;
            *user_ptr_del = NULL;
            free(temp);
            return 0;
        } else {
            return 1;
        }
    }

    // If 1st element is to be removed
    if (strcmp(curr->name, name) == 0) {
        temp = curr;
        *user_ptr_del = curr->next;
        remove_friends(name, user_ptr_del);
        free(temp);
        return 0;
    }

    // Iterate through the users until the end of the list is reached,
    // or until the name of curr matches the name of the deleted user
    while (strcmp(curr->next->name, name) != 0 && curr->next != NULL) {
        curr = curr->next;
    }
        // If name does not exist
    if (curr->next == NULL) {
        free(temp);
        return 1;
    }

    // If user to be removed is the last one
    if (curr->next->next == NULL) {
        temp = curr->next;
        curr->next = NULL;
    } else {
        // If user to be removed is in the middle of the list
        temp = curr->next;
        curr->next = curr->next->next;
    }

    // Remove the user from the friendlists of every user
    remove_friends(name, user_ptr_del);

    Post *curr_post = temp->first_post;
    while (curr_post != NULL) {
        free(curr_post->date);
        free(curr_post);
        curr_post = curr_post->next;
    }

    // Free the memory in temp
    if (temp != NULL) {
        free(temp);
        temp = NULL;
    }
    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.
 */