hansolo_17 hansolo_17 - 3 years ago 90
C Question

memory allocated by NULL pointers

Does NULL pointer take any memory?
If it takes memory,then how much memory is consumed by it and what is the significant use of NULL pointer if it takes memory?

Answer Source

A pointer value (NULL or not) requires some amount of space to store and represent (4 to 8 bytes on most modern desktop systems, but could be some oddball size depending on the architecture).

The pointer value NULL represents a well-defined "nowhere"; it's an invalid pointer value guaranteed to compare unequal to the address of any object or function in memory. The macro NULL is set to the null pointer constant, which is a zero-valued integer expression (either a naked 0, or (void *) 0, or some other expression that evaluates to 0).

After the code has been compiled, the null pointer constant will be replaced with the appropriate null pointer value for that particular platform (which may be 0x00000000, or 0xFFFFFFFF, or 0xDEADBEEF, or some other value).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download