C: Segmentation fault, doubly linked list <p>i am fairly new to C and i have a Problem. Everytime i run the programm i get a "Segmentation fault" and i don't know why. I am pretty sure i know were the problem comes from, so i maked the line in the code. I hope you can help me. Thanks in advance.</p> <pre><code>struct node { struct node *next; struct node *previous; char data[255]; }; void insert(char *value, struct node **anf, struct node **end) { struct node *var,*temp; var=(struct node *)malloc(sizeof(struct node)); strcpy(var-&gt;data, value); if(*anf==NULL) { *anf=var; (*anf)-&gt;previous=NULL; (*anf)-&gt;next=NULL; *end=*anf; } else { temp=var; temp-&gt;next=NULL; temp-&gt;previous=*end; (*end)-&gt;next=temp; *end=temp; } } int einlesen(char *quelldatei, struct node **anf, struct node **end) { FILE *datei; if ((datei=fopen(quelldatei,"r")) == NULL) { return 1; } else { char string[255]; while(fgets (string, 255, datei)!=NULL) { if (string[strlen(string)-1]=='\n') { char newstring[strlen(string)-1]; int i; for(i = 0; i &lt; sizeof(newstring); i++) { newstring[i]=string[i]; } newstring[sizeof(newstring)]= '\0'; insert(newstring, anf, end); //NOT WORKING } else { insert(string, anf, end); //NOT WORKING } } fclose(datei); return 0; } } int main(int argc, char * argv[]) { struct node *anf,*end; int a = einlese(##FILENAME##,&amp;anf,&amp;end); //##FILENAME## stands for a local file return 0; } </code></pre>