Thread: 0 & Null?

  1. #1
    Registered User tu_user's Avatar
    Join Date
    Jan 2004
    Posts
    36

    Arrow 0 & Null?

    Well its just a general programming question. I was going through a topic in which it was clearly written that c++ prefer 0 and not NULL. I wanted to ask that if there is any solid difference btw 0 and NULL?

  2. #2
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    I use NULL with pointers, 0 for everything else. And also 'false' when I can, especially with booleans.

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078

    Re: 0 & Null?

    Originally posted by tu_user
    I wanted to ask that if there is any solid difference btw 0 and NULL?
    In C? Yes.
    In C++, No.

    In C, NULL is defined as 0 typecast to a void pointer, where-as in C++ it's literally defined as 0.

  4. #4
    Registered User tu_user's Avatar
    Join Date
    Jan 2004
    Posts
    36

    Lightbulb

    Okeys thankx but u answered only one part of the question. But y? c++ prefers 0 over NULL?

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by tu_user
    Okeys thankx but u answered only one part of the question. But y? c++ prefers 0 over NULL?
    http://www.research.att.com/~bs/bs_faq2.html#null

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  2. Help with yacc/compiler design/seg fault
    By trippeer in forum C Programming
    Replies: 1
    Last Post: 04-08-2005, 03:43 AM
  3. Wierd Segmentation Faults on Global Variable
    By cbranje in forum C Programming
    Replies: 6
    Last Post: 02-19-2005, 12:25 PM
  4. Big Problem With Passing an Matrix to Main Function
    By Maragato in forum C Programming
    Replies: 4
    Last Post: 06-14-2004, 11:06 PM
  5. Really Need Help With My Opengl Camera!!!!
    By psychopath in forum Game Programming
    Replies: 13
    Last Post: 05-28-2004, 03:05 PM