Debugging your { C #code }
Segmentation fault (core dumped) T hat's the dreaded message the program crashed with, after hours of clacking the keyboard keys to build a custom BigNum library for C. The consequence? I had to spend another hour, dry-testing the code trying to pin-point the source of the fault. The crash, no doubt resulted from an illegal memory reference; this could mean anything from a NULL pointer access to an illegal array index to out of memory error. For source codes amounting to thousands of lines or more, hunting bugs is equivalent to finding the needle in a haystack. We could instead make our life much easier if we had some mechanism to track the source of such faults in C. The code excerpts in this article were compiled and tested with GCC. I'm not sure how compatible it is with other compilers, but I'm sure it wouldn't be a problem for other than some few pre-defined macros. C++ has some help from its exception handling. Java does it better, thanks to its byte-c...