C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 3)
3.
In which header file is the NULL macro defined?
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 1 of 5.
Dipak said:
4 years ago
STDDEF.C is a header file.
Am I right?
Am I right?
(2)
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, ...
Prutha said:
1 decade ago
What is the use of null macro? why is an empty pointer required?
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.
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.
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
Sasikumar said:
1 decade ago
Thanks bijan.
Meenu said:
1 decade ago
What is the function of null macro ?
Dhrumil said:
1 decade ago
stdio.h and stddef.h is what ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers