CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
Is NULL always defined as 0?
Category C Interview Questions
Rating (4.8) By 24 users
Added on 10/22/2004
Views 3757
Rate it!
Answers:

NULL is defined as either 0 or (void*)0. These values are almost identical; either a literal zero or a void pointer is converted automatically to any kind of pointer, as necessary, whenever a pointer is needed (although the compiler can?t always tell when a pointer is needed).



#include<stdio.h>
int main()
{
if(NULL==(void *)0)
printf("true");
else
printf("false");

if(NULL == 0)
printf(" Value is zero");
getch();
}
This gives the output as
True
Value is Zero



 Posted by: Syed Baseer Ahmed    

Contact Syed Baseer Ahmed  Contact Syed Baseer Ahmed

NULL in c is defined as a macro in stdio.h as
#define NULL 0
as we know that we don't have to include the stdio directive we can access the NULL



 Posted by: mahanth hiremth    

Contact mahanth hiremth  Contact mahanth hiremth

it's depend on system but default is zero....



 Posted by: khaja    

Contact khaja  Contact khaja


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
What does it mean when a pointer is used in an if statement?
View Answer
Can you add pointers together? Why would you?
View Answer
How do you use a pointer to a function?
View Answer
When would you use a pointer to a function?
View Answer
Why should we assign NULL to the elements (pointer) after freeing them?
View Answer
Is it better to use malloc() or calloc()?
View Answer
What is the difference between far and near?
View Answer
When should a far pointer be used?
View Answer
Can the size of an array be declared at runtime?
View Answer
What is the heap?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/1007/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.81