CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

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 (1.0) By 200 users
Added on 11/22/2013
Views 1671
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 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 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 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 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.

Post your answer here

Inform me about updated answers to this question.
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




India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.031982 Seconds