Every time I try to extract data from a file that I have, it extracts the 2 first numbers and then it throws me a Segmentation fault. Here's the code of the two functions that are used:
When I try to run it, it extracts the first 2 numbers and then I get a Segmentation fault, and gdb says this:Code:void extraer() { primer = ult = NULL; //primer = first node ; ult = last node; int numero; FILE *fichero; fichero=fopen("datos.txt", "r"); if (fichero==NULL) { printf("\nEl fichero no existe\n"); menu(); } while(!feof(fichero)) { struct lista *neue; neue = new lista; fscanf(fichero, "%d", &numero); neue->id=numero; metelist(neue); //Inserts the node with the value into the list } fclose(fichero); } void metelist(struct lista *neue) //Pushes the node into the linked list { if(primer==NULL) { primer = neue; ult = neue; } else { primer->next = neue; ult = ult->next; } neue->next = NULL; ult->next = NULL; }
I'm sorry if it's a noobish question.Code:Program received signal SIGSEGV, Segmentation fault. 0x0000000000400fae in metelist(lista*) ()



LinkBack URL
About LinkBacks


