Вопрос

when running my code in borland c 3.1 it works fine, but when running it on c-free it crashes at this line: while(ptr1->pright) { ptr1=ptr1->pright; } giving SIGSEGV, any logical reasons?

Это было полезно?

Решение

You're probably accessing memory outside the bounds of an array or which you didn't allocate. As such, you triggered undefined behaviour, so pretty much anything can happen, including crashing or even apparently working fine.

Другие советы

When creating/initialising your linked list's nodes make sure to explicitly initialise the node's member pright to NULL.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top