#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *next;
}node;
void init(node* head, node* tail){
head = (node*)malloc(sizeof(node));
tail = (node*)malloc(sizeof(node));
head->next = tail;
tail->next = tail;
}
void push(node* head, int data){
node *temp;
temp = (node*)malloc(sizeof(node));
if(temp == NULL){
printf("%s", "Out Of Memory");
}else{
temp->data = data;
temp->next = head->next;
on the next Line, there there's printf method which print number 7. It's for debug. but this printf methods didn't worked. so I noticed
temp->next = head->next;
this code has an error. but I couldn't find the reason.. I was thinking of memory allocation issue. but still didn't get it..!
printf("%d", 7);
head->next = temp;
printf("push (%d)", data);
}
}
void main(){
node* head = NULL;
node* tail = NULL;
init(head, tail);
push(head, 10);
}