Search code examples
csegmentation-faultturbo-c

my c code crashes when running it on c-free but works fine on borland?


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?


Solution

  • 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.