質問

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