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.
Nani said:
1 decade ago
I understand that
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.
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.
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.
Prasanna said:
1 decade ago
Macro is available in stdlib.h, stddef.h, locale.h. etc.,
We know that NULL represents nothing. But it should have some value. While using NULL in program we may get garbage value. So to avoid that garbage values. NULL macro defines that NULL is "0". So in program if we got any null value that will be taken as zero.
We know that NULL represents nothing. But it should have some value. While using NULL in program we may get garbage value. So to avoid that garbage values. NULL macro defines that NULL is "0". So in program if we got any null value that will be taken as zero.
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.
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.
Varsha said:
1 decade ago
NULL Pointer is a pointer which is pointing to nothing. It points the base address of segment.
In case, if you don't have address to be assigned to pointer then you can simply use NULL Pointer which is initialized with NULL value is considered as NULL pointer.
In case, if you don't have address to be assigned to pointer then you can simply use NULL Pointer which is initialized with NULL value is considered as NULL pointer.
Tasneem said:
1 decade ago
Hay stdlib is a header file, you can also see the functions include in the header file in turbo c software.
Can anybody explain what is null macro and what kind of functions the stddef header file includes.
Can anybody explain what is null macro and what kind of functions the stddef header file includes.
Sundar said:
1 decade ago
@Vanitha
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.
Have a nice day!
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.
Have a nice day!
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.
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.
Anyhow, including the both header files stdio.h and stddef.h WILL NOT create any problem.
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, ...
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers