C Programming - Pointers - Discussion

Discussion Forum : Pointers - General Questions (Q.No. 3)
3.
In which header file is the NULL macro defined?
stdio.h
stddef.h
stdio.h and stddef.h
math.h
Answer: Option
Explanation:
The macro "NULL" is defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, and wchar.h.
Discussion:
48 comments Page 3 of 5.

Bijan said:   1 decade ago
NULL Macro is simply what is defined as 0 in a macro provided by the library

Null macro is defined in stdio.h and stddef.h.It is used to represent a null pointer in your code.

its value is zero.

Null pointer is same as an uninitialized pointer..It does not point anywhere.

Riya said:   1 decade ago
Thnks bijan.

Deependra rathore said:   1 decade ago
stddef.h is stands for standard definition called it is uses for some exceptional condition

Om prakash said:   1 decade ago
Include any one of the header files stdio.h or stddef.h, it is enough to use NULL.

Anyhow, including the both header files stdio.h and stddef.h WILL NOT create any problem.

Prutha said:   1 decade ago
What is the use of null macro? why is an empty pointer required?

Akbar said:   1 decade ago
The <stddef.h> header defines the following: NULL: Null pointer constant. offsetof(type, member-designator): Integral constant expression of type size_t, ...

Ganesh said:   1 decade ago
There's no reason. NULL is more commonplace whereas 0 looks like an
integer, but people use both ways all the time.

I think in C NULL is defined as 0. In C++ it is (void*)0.

Ganesh said:   1 decade ago
Both are very different.

NULL macro is
#define NULL 0

It means the macro NULL will be replaced by 0 while pre-processing. But the NULL pointer means it points to nowhere i.e. contains 0. It contains 0 means it may be dangerous to use such pointer without assigning proper address to it otherwise NULL pointer may try to access reset address may cause the program to crash.

Hadeer said:   1 decade ago
As pointer can point to anywhere in memory& maybe enter to code area &anywhere that I don't want so we use null. Null like intialize value to pointer.

Jhansi said:   1 decade ago
What Mr. Ganesh said is true. using NULL pointer is very Dangerous


Post your comments here:

Your comments will be displayed after verification.