Hello I am so confused about this, I hope you can help me. Here is my code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct node{
int x;
struct node *next;
struct node *prev;
};
typedef struct node NODE;
NODE * create(int data)
{
NODE *newn;
newn=(NODE*)malloc(sizeof(NODE));
newn->x=data;
newn->next=NULL;
newn->prev=NULL;
return newn;
}
int insert(NODE *list, int data)
{
NODE *temp,*news;
temp=list;
if(list==NULL)
{
list=create(data);
return 0;
}
}
int main()
{
int put;
NODE *mList=NULL;
clrscr();
printf("data: ");
scanf("%i",&put);
insert(mList,put);
}
It is a very simple doubly linked list but I cannot even start inserting because I cannot even put value into the first node. When I create the new node in create, the newn->x will have the right value, and list->x (in insert) will also have the right value but when it goes back to main, mList->x is still 0.