+ 2
Can anybody finds the mistake i did in this code?
I am trying to create two different Linkedlist using one program. https://code.sololearn.com/cbiocIBOxLTg/?ref=app
3 Antworten
+ 1
llist1 and llist2 contains so called garbage data if you dont init them and, because of that, at first insert, the program try to dereferenciate pointer (next node) that point to not allocated memory obtaining a segmentation fault.
You have to init either with manual init or with the getNewNode funcion.
P.S. Dont forget to implement code for deallocation
+ 1
Read the comments of following edited code
https://www.sololearn.com/compiler-playground/cN9POa7pjj7p/#c
I would like add to hints.
1) Start to handle memory deallocation too
2) Your would better compoisiting a List data structure adding a List structure that contains a pointer to first node and add functions on manage the nodes