c - Char Doubly-linked list -


i've created structure , function doubly linked list. works flawlessly integers have convert use characters. i've had problem when comes characters, when put in character constant loop.

so far have :

 struct node {       struct node *previous;       char data;       struct node *next; }*head, *last;    void begin(char value)  {      struct node *temp;  char *var=(char *)malloc(sizeof(char)*100);  var->data=value;  if(head==null)  {      head=var;      head->previous=null;      head->next=null;      last=head;  }  else  {      temp=var;      temp->previous=null;      temp->next=head;      head->previous=temp;      head=temp;  } }  

i used examples previous push/pop function used characters i'm not sure i'm doing wrong.

edit: forgot put errors> null.c:14: error: request member `data' in not structure or union null.c:17: warning: assignment incompatible pointer type

char *var=(char *)malloc(sizeof(char)*100); 

this should be,

struct node *var= malloc( sizeof( struct node ) ); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -