How to assign a string to a node

Hi guys, I've got a quick question here.

I'm creating a linked list in C, and I'm trying to get a string from the user and store it into a node. So I have:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct node {
     struct node *next;
     char name[19]; //stores the string
};

struct node *head;
head = NULL;
char cName[19];

struct node *n;
n= malloc(sizeof(struct node));
scanf("%s",cName);

n->name=cName; //this does not work
n->next=head;
head->n;


PLEASE tell me you don't have to process the string into the other string like an array. Thanks.
There's a standard function that copies it for you:

 
strcpy(n->name, cName);
Awesome thanks.
Topic archived. No new replies allowed.