CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES C DETAILS
    Question :
    If NULL and 0 are equivalent as null pointer constants, which should I use?
    Category C Interview Questions
    Rating (0.2) By 32 users
    Added on 11/17/2011
    Views 172
    Rate it!
    Answers:

    Many programmers believe that NULL should be used in all pointer contexts, as a reminder that the value is to be thought of as a pointer. Others feel that the confusion surrounding NULL and 0 is only compounded by hiding 0 behind a macro, and prefer to use unadorned 0 instead. There is no one right answer. C programmers must understand that NULL and 0 are interchangeable in pointer contexts, and that an uncast 0 is perfectly acceptable. Any usage of NULL (as opposed to 0) should be considered a gentle reminder that a pointer is involved; programmers should not depend on it (either for their own understanding or the compiler's) for distinguishing pointer 0's from integer 0's.
    It is only in pointer contexts that NULL and 0 are equivalent. NULL should not be used when another kind of 0 is required, even though it might work, because doing so sends the wrong stylistic message. (Furthermore, ANSI allows the definition of NULL to be ((void *)0), which will not work at all in non-pointer contexts.) In particular, do not use NULL when the ASCII null character (NUL) is desired. Provide your own definition
    #define NUL ''
    if you must.



    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.
  • 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
    Should I use symbolic names like TRUE and FALSE for Boolean constants, or plain 1 and 0?
    View Answer
    What is Hungarian Notation? Is it worthwhile?
    View Answer
    People always say that good style is important
    View Answer
    I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
    View Answer
    How can I shut off the warning ...
    View Answer
    Where can I get an ANSI-compatible lint?
    View Answer
    Dont ANSI function prototypes render lint obsolete?
    View Answer
    I need code to parse and evaluate expressions.
    View Answer
    How can I find out if there are characters available for reading?
    View Answer
    How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
    View Answer
    How can I make it pause before closing the program output window?
    View Answer
    How do I read the arrow keys? What about function keys?
    View Answer
    How can I do serial comm port I O?
    View Answer
    How can I direct output to the printe
    View Answer
    How do I send escape sequences to control a terminal or other device?
    View Answer
    How can I access an I O board directly?
    View Answer
    How can I do graphics in C?
    View Answer
    How can I send mail from within a C program?
    View Answer
    How can I check whether a file exists? I want to warn the user if a requested input file is missing.
    View Answer
    How can I find out the size of a file, prior to reading it in?
    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 C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 2.328125 Seconds