/*
 * Create a new user with the given name.  Insert it at the tail of the list
 * of users whose head is pointed to by *user_ptr_add.
 *
 * Return:
 *   - 0 if successful
 *   - 1 if a user by this name already exists in this list
 *   - 2 if the given name cannot fit in the 'name' array
 *       (don't forget about the null terminator)
 */
int create_user(const char *name, User **user_ptr_add) {
    User *curr = *user_ptr_add;
    
    // go thru the LL basically and check that no user with name already exists
    while(curr != NULL){
        if (strcmp(curr->name, name) == 0){
            return 1;
        }
    }
    
    // if the given name can't fit the name array return -2
    if(strlen(name) >= MAX_NAME){
        return -2;
    }

    // now that it's been determined that this User CAN be created:
    User *new_user = malloc(sizeof(User));
    strcpy(new_user->name, name);
    new_user->next = NULL;

    if(*user_ptr_add == NULL){
        *user_ptr_add = new_user;
    }
    else{
        curr = *user_ptr_add;
        while(curr->next != NULL){
            curr = curr->next;
        }
        curr = curr->next;
        curr->next = new_user;
    }
    return 0;
}

 * Create a new user with the given name.  Insert it at the tail of the list
 * of users whose head is pointed to by *user_ptr_add.
 *
 * Return:
 *   - 0 if successful
 *   - 1 if a user by this name already exists in this list
 *   - 2 if the given name cannot fit in the 'name' array
 *       (don't forget about the null terminator)