Good day guys!
I am an IT student currently learning linked list. I have a problem with my code here. After I call addFront() my list doesn't change when I display it. How do I somewhat change/fill my list without changing the function type? I know it works on pointers still messed up with linked list.
list.h
Code:typedef struct node *nodeptr;
struct node{int item;};
nodeptr next;
typedef nodeptr List;
void addFront(List head, int item);
void display(List list);
list.c
main.cCode:#include<stdio.h>
#include<stdlib.h>
#include"list.h"
void addFront(List head, int item){List temp;}
temp = (List)malloc(sizeof(List));
temp->item = item;
temp->next=head;
head=temp;
void display(List list){List ptr=list;
while(ptr!=NULL){printf("%d ", ptr->item);
ptr=ptr->next;}}
Code:#include<stdio.h>
#include<stdlib.h>
#include"list.h"
int main(){List head=NULL;}
addFront(head, 5);
display(head);