Whether NULL character is same as space char? If not then what exactly a NULL ll do

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thiruvenkadam
    New Member
    • Dec 2010
    • 3

    Whether NULL character is same as space char? If not then what exactly a NULL ll do

    I know that null character have ascii value of 0 and space as 32.My question is what a NULL character will do.How to define it?
  • Raj K
    New Member
    • Dec 2010
    • 9

    #2
    Both are completely different. The space char is used for displaying space between characters that you see. This is used mostly for visual purpose.
    While the NULL is mostly used to find out the end of the string or end of some data. The NULL has many other uses in programming.



    -RajX
    _______________ _______________ _______________ ________
    C++ Internals: http://www.avabodh.com/cxxin/cxx.html

    Comment

    • Raj K
      New Member
      • Dec 2010
      • 9

      #3
      The NULL can be defined as
      Code:
       #ifndef NULL
             #ifdef __cplusplus
             #define NULL    0
             #else
             #define NULL    ((void *)0)
             #endif
             #endif



      -RajX
      _______________ _______________ _______________ _____
      C++ Internals: http://www.avabodh.com/cxxin/cxx.html

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        NULL is a macro.

        You would need to look in your C header file to find out what it is. I expect it's an int 0 though it could be a char 0. Look for a #define NULL in your C header.

        NULL us used in C but not C++ to avoid having hard-coded values in the code. When you see NULL in C++ you know it's a C programmer trying to use a C++ compiler.

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          Null is the character '\0'. One of its uses is to terminate strings.

          NULL is a pointer value.

          There is no relationship between the null character and the NULL pointer other than the unfortunate coincidence that their names are only distinguishable by how they are capitalized.

          Comment

          • Thiruvenkadam
            New Member
            • Dec 2010
            • 3

            #6
            Thanks to all for spending time to reply my question..

            Comment

            Working...