C fifo linked list char push -
i'm trying understand fifo linked list , found example here example , , i'm trying input char instead of int
#include <stdio.h> #include <conio.h> #include <stdlib.h> struct node { char data; struct node* next; }*rear, *front; void delqueue() { struct node *temp, *var=rear; if(var==rear) { rear = rear->next; free(var); } else printf("\nqueue empty"); } void push(char *value) { struct node *temp; temp=(struct node *)malloc(sizeof(struct node)); temp->data=value; if (front == null) { front=temp; front->next=null; rear=front; } else { front->next=temp; front=temp; front->next=null; } } void display() { struct node *var=rear; if(var!=null) { printf("\nelements as: "); while(var!=null) { printf("\t%d",var->data); var=var->next; } printf("\n"); } else printf("\nqueue empty"); } int main() { int i=0; char ch; front=null; printf(" \n1. push queue"); printf(" \n2. pop queue"); printf(" \n3. display data of queue"); printf(" \n4. exit\n"); while(1) { printf(" \nchoose option: "); //scanf("%d",&i); ch = getchar(); switch(ch) { case '+': { char value[20]; printf("\nenter valueber push queue : "); scanf("%s", value); push(value); printf("%s",value); display(); break; } case '-': { delqueue(); display(); break; } case '*': { display(); break; } case '$': { exit(0); } default: { printf("\nwrong choice operation"); } } } } i can't understand warning on line 26: warning: assignment makes integer pointer without cast
i can input text, example: "hello world", when want display it, showed "-9". confused.
data defined char, assigning char * (char pointer) it. creates warning, , surely won't work expect.
Comments
Post a Comment