Hello I have a problem with my code its shows this error: "Segmentation fault: 11" here is my code i'm trying to make a program that convert binary linked list to decimal using lists in C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct cellule{
int b;
struct cellule* Next;
}Cellule;
typedef Cellule* liste;
int BinToEntier(liste a){
int n;
int j=0;
liste p=NULL;
for (p=a; p->Next!=NULL; p=p->Next) {
n+=(p->b)*pow(2,j);
j++;
}
return n;
}
int main() {
liste a=NULL;
liste p;
a= (liste) malloc(sizeof(Cellule));
p=a;
for (int i = 0; i < 4; i++) {
puts("enter b");
scanf("%i", &(p->b));
p=p->Next;
}
printf("%i\n", BinToEntier(a));
return 0;
}