Trouble adding string to LinkedList in C -


i want add string linked list in c. able figure out how add integer, thought adding string wouldn't different. tried following:

struct node{    char val;    struct node * next; };  typedef struct node item;  void linked_list(char letter[]) {     item * curr, * head;     int i;      head = null;      curr = (item *)malloc(sizeof(item));     curr->val = letter;     curr->next  = head;     head = curr;           curr = head;      while(curr) {         printf("%s\n", curr->val);         curr = curr->next ;     } } 

however, keep getting an

assignment makes integer pointer without cast

warning and

format '%s' expects type 'char *', argument 2 has 'int'

if, in struct, val character, why getting error?

side note: char letter[] passing in letters/characters separate main method.

i learning c , linked lists tutorial:http://www.learn-c.org/en/linked_lists.

val char, number between 0 - 255.

what want char *, string.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -