I've created a structure and function for a doubly linked list. It works flawlessly for integers but now I have to convert it to use characters. I've always had a problem when it comes to characters, also when I put in a character I get a constant loop.
So far I 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 some examples from my previous push/pop function which used characters but I'm not sure what I'm doing wrong.
Edit: Forgot to put errors> null.c:14: error: request for member `data' in something not a structure or union null.c:17: warning: assignment from incompatible pointer type