/*
 * Make two users friends with each other.  This is symmetric - a pointer to
 * each user must be stored in the 'friends' array of the other.
 *
 * New friends must be added in the first empty spot in the 'friends' array.
 *
 * Return:
 *   - 0 on success.
 *   - 1 if the two users are already friends.
 *   - 2 if the users are not already friends, but at least one already has
 *     MAX_FRIENDS friends.
 *   - 3 if the same user is passed in twice.
 *   - 4 if at least one user does not exist.
 *
 * Do not modify either user if the result is a failure.
 * NOTE: If multiple errors apply, return the *largest* error code that applies.
 */
int make_friends(const char *name1, const char *name2, User *head) {
    int largest_error = 0;
    User *user_1 = find_user(name1, head);
    User *user_2 = find_user(name2, head);
    // If the same user is passed in twice 
    if (user_1 == user_2) {
        if (largest_error < 3){
            largest_error = 3;
        }
    }
    // If at least one user doesn't exists
    if (user_1 == NULL || user_2 == NULL) {
        if (largest_error < 4){
            largest_error = 4;
        }
    }
    // Go through user_1's friend's list
    User *curr = user_1->friends[0];
    User *curr2 = user_2->friends[0];
    int num_user1 = 0;
    int num_user2 = 0;
    int not_friends = 0; 
    while (curr->next != NULL) {
        // Go through user_2's friend's list 
        while (curr2->next != NULL) {
            // If the two users are already friends
            if (curr2 == curr) {
                not_friends += 1;
                if (largest_error < 1) {
                    largest_error = 1;
                }
            }
            curr2 = curr2->next;
            num_user2 += 1;
        }
        curr = curr->next;
        num_user1 += 1;
    }
    // If users are not already friends but one of them have max number of friends
    if (not_friends != 0 && (num_user1 == MAX_FRIENDS || num_user2 == MAX_FRIENDS)) {
        if (largest_error < 2) {
            largest_error = 2;
        }
    }
    // Success
    else if (not_friends == 0 && (num_user1 < MAX_FRIENDS && num_user2 < MAX_FRIENDS)) {
        curr->next = user_2;
        curr2->next = user_1;
    }
    return largest_error;
}
Get rid of segmentation fault