Interview Questions

What does a run-time null pointer assignment error mean?

C Interview Questions and Answers


(Continued from previous question...)

What does a run-time null pointer assignment error mean?

Q: What does a run-time ``null pointer assignment'' error mean? How can I track it down?

A:This message, which typically occurs with MS-DOS compilers, means that you've written, via a null pointer, to an invalid location--probably offset 0 in the default data segment. (The pointer in question might have been uninitialized, not all uninitialized pointers necessarily start out as null pointers.)
A debugger may let you set some kind of data watchpoint on location 0. Alternatively, you could write a bit of code to stash away a copy of 20 or so bytes from location 0, and periodically check that the memory at location 0 hasn't changed.

(Continued on next question...)

Other Interview Questions