+ 6
Could you tell how to fix the problem with segmentation fault core damped?
When we run this code in gcc cygwin, up to 2 nodes this program works fine, but when we define 3rd node the gcc compiler show : segmentation fault core damped (I gues this code does not work on sololearn, so it is better to test in desktop or in laptop): https://code.sololearn.com/c7Gn4AAu085q/#c
18 odpowiedzi
+ 9
I found it
in your tree nodes when you allocate memory you set just key and value
there is left and right pointers must be set to null
use calloc instead of malloc to initilize the memory to zero (and NULL)
or set it manually like
tmp->left->left=tmp-left-right=NULL;
I just changed malloc to calloc in your code and it is done
+ 7
tru to use debugger to see where is the bug at runtime
or show me the code
+ 5
That happens when you access memory that is not yours. For example you use a pointer after freeing, you dereference an invalid pointer, you read past array bounds, that sort of thing.
Really hard to tell without looking at the code.
+ 5
install codeblocks , it is good and helpful
also it is easy to install
+ 5
yes it needs but all of that comes together in one package
+ 5
you're welcome 🤩
+ 4
Schindlabua now please see the attached link of the code
+ 4
ABADA S would you help to install an ide with debugger that can be installed on e disk that is not the main disk c
+ 4
ABADA S does it need mingw? or gcc or something like this?
+ 4
ABADA S how much memory does it need and can it be installed in e disk which is not the operational system disk?
+ 4
ABADA S would you send a link of the code blocks that you are using?)
+ 4
ABADA S thanks, bro!)
+ 3
ABADA S would you send your modification please?)
+ 3
ABADA S By the way therealso trouble in contains_key, it returns 0 ifit contains key and also there is similar trouble with get_value
+ 3
Examine the core file with gdb using your binary as reference. I can't do it either. On the train myself 😉.
+ 2
I'm on a train at the moment so I can't check with gcc and gdb, I'm sorry :/ Maybe someone else can step in..