Hello
I have written an infinite loop but i cannot understand wy?
I want to add in the front of a linked list a new struct and after that i want to print it.
Code:#include <stdio.h>
#include <stdlib.h>
typedef int element;
struct cell {
element e;
struct cell *p;
};
typedef struct cell* cel;
cel addInFront (cel l, element i);
void writeList (cel l);
int main (void){
cel list;
list = NULL;
list = addInFront (list, 5);
list = addInFront(list, 4);
writeList (list);
return 0;
}
void writeList (cel l){
while (l != (cel )NULL){
printf("\t %d", l->e);
writeList (l->p);
}
}
cel addInFront ( cel l, element i){
cel p;
p = (cel) malloc (sizeof(struct cell));
p->e = i;
p->p = l;
return p;
}