|
INTERVIEW QUESTIONS
C
POINTERS IN C
DETAILS
Question: Difference between :- 1) NULL pointer and NULL macro ?
Answer: Both are very different. NULL macro is #define NULL 0 it means the macro NULL will be replaced by 0 while preprocessing 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.
|
|
|
Category |
Pointers in C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9688 users |
Added on |
11/22/2013 |
Views |
67566 |
Rate it! |
|
|
Question:
Difference between :- 1) NULL pointer and NULL macro ?
Answer:
Both are very different. NULL macro is #define NULL 0 it means the macro NULL will be replaced by 0 while preprocessing 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. Source: CoolInterview.com
Answered by: Vikas | Date: 11/26/2008
| Contact Vikas
NULL macro is defined in stdio.h/stddef.h and represents a zero. Any pointer pointing to 0x0 location is null pointer. Be careful there is a difference between null pointer and dangling pointer. Source: CoolInterview.com
Answered by: Vikram | Date: 12/18/2008
| Contact Vikram
null pointer is a pointer that is pointing nothing while NULL macro will used for replacing 0 in program as #define NULL 0 Source: CoolInterview.com
Answered by: abhishek pathak MCA from allahabad | Date: 7/29/2009
| Contact abhishek pathak MCA from allahabad
The language definition states that for each pointer type, there is a special value--the ``null pointer''--which is distinguishable from all other pointer values and which is ``guaranteed to compare unequal to a pointer to any object or function.'' That is, a null pointer points definitively nowhere; it is not the address of any object or function. The address-of operator & will never yield a null pointer, nor will a successful call to malloc.[footnote] (malloc does return a null pointer when it fails, and this is a typical use of null pointers: as a ``special'' pointer value with some other meaning, usually ``not allocated'' or ``not pointing anywhere yet.'')
A null pointer is conceptually different from an uninitialized pointer. A null pointer is known not to point to any object or function; an uninitialized pointer might point anywhere.
As mentioned above, there is a null pointer for each pointer type, and the internal values of null pointers for different types may be different. Although programmers need not know the internal values, the compiler must always be informed which type of null pointer is required, so that it can make the distinction if necessary Source: CoolInterview.com
Answered by: Deepanchakkaravarthy.K | Date: 2/15/2010
| Contact Deepanchakkaravarthy.K
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is :- pointer , NULL pointer , dangling pointer , far pointer , near pointer , huge pointer , generic pointer , smart pointer ?
|
View Answer
|
|
In a recursive definition of a list node shown below, how can we predefine NODEPTR ?
typedef struct _NODE { INFOTYPE info; NODEPTR link; };
|
View Answer
|
|
Is **p and &(*p) same?
|
View Answer
|
|
What are the uses of pointers in c and c++ language?
|
View Answer
|
|
what is the difference between near pointer and far pointer?
|
View Answer
|
|
What is file pointer and its working method?
|
View Answer
|
|
How I can add two numbers in c language without using Arithmetic operators?
|
View Answer
|
|
What is pointer?
|
View Answer
|
|
What are the disadvantages of using Pointers.
|
View Answer
|
|
How to operate pointers in any pragram & how to develop our logic while implementing pointer
|
View Answer
|
|
Difference between arrays and pointers?
|
View Answer
|
|
What is the difference between NULL and NUL?
|
View Answer
|
|
What is a null pointer?
|
View Answer
|
|
What is a const pointer?
|
View Answer
|
|
What is pointer?
|
View Answer
|
|
What do you mean by normalisation of pointers
|
View Answer
|
|
Following declarations are same const char *s; char const *s;
|
View Answer
|
|
In the following code, what is p2?
typedef int* ptr
ptr p1, p2;
|
View Answer
|
|
In the following code, what is p2?
typedef int* ptr
ptr p1, p2;
|
View Answer
|
|
What is far pointer?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Pointers in C Interview Questions & Answers - Exam Mode /
Learning Mode
|