I'm trying to make a linked list, what's wrong with my syntax for adding a node?

struct data {
     char name[20];   
     char number[10]; 
};

typedef struct node {
     struct data list;
     struct node* next;
} Node;

Node *head = 0;
Node *tail = 0;
Node *New = 0;

void add(char* name, char* number) {
    New = (Node *) malloc(sizeof(Node));
    New->list.name = name;   /* incompatible type assignment, from char* to char[20] */
    New->list.number) = number;   /* same error */
    New->next = 0;

    if (tail != 0) {
        tail->next = New;
        tail = New;
    }
    else {
        tail = New;
        head = New;
    }
}

You can't assign an array of characters like that, here is how you correct it.

#include <stdio.h>

struct data {
     char name[20];   
     char number[10]; 
};

typedef struct node {
     struct data list;
     struct node* next;
} Node;

Node *head = 0;
Node *tail = 0;
Node *New = 0;

void add(char* name, char* number) {
    New = (Node *) malloc(sizeof(Node));
    sprintf_s( New->list.name, 20, name );
    sprintf_s( New->list.number, 10, number );
    New->next = 0;

    if (tail != 0) {
        tail->next = New;
        tail = New;
    }
    else {
        tail = New;
        head = New;
    }
}

Hope this helps :)

edit: heh, just realized its already been marked as solved ;)

This question has already been answered. Start a new discussion instead.