#include "friends.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

/*
 * 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) {
    // Don't add a user if their name already exists in the list but still add 
    // user in if their name doesn't fit array and their name is unique.

    // Step 1: Traverse through user linked list
    User **curr = user_ptr_add;
    if (user_ptr_add != NULL) {
        while (*curr->next != NULL){
            if (name == *curr->name){
                return 1;
            }
            curr = *curr->next;
        }
    }
    // Turn name into a char array
    char *temp_username; 
    strcat(temp_username, name);
    char *username;
    strncpy(temp_username, username, MAX_NAME - 1);

    // Step 1 - if user linked list is empty OR 
    // Step 2: if we have completed traversing through linked list and curr -> name != username
    if (user_ptr_add == NULL || username != *curr->name) {
        // Create new user with name
        User *new_user = (User *)malloc(sizeof(User));
        // Copy username into new_user 
        strncpy(username, new_user->name, MAX_NAME - 1); 

        // Checks if it's an empty user list or not and insert user
        if (user_ptr_add == NULL) {
            user_ptr_add = new_user;
        }
        else {
            // sets the last user's next to point to new_user
            *curr->next = new_user;
        }

        // Check length of name
        if (strlen(name) >= MAX_NAME) {
            return 2;
        }
        else{
            return 0;
        }
    }
    else { // if the last user has the same name as the user we wanted to insert 
        return 1;
    }
}

How to get rid of error "member reference base type 'User *' (aka 'struct user *') is not a structure or union"