By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

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

P: 3
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?
Dec 9 '10 #1

✓ answered by Raj K

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

Share this Question
Share on Google+
5 Replies


P: 9
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
Dec 9 '10 #2

P: 9
The NULL can be defined as
Expand|Select|Wrap|Line Numbers
  1.  #ifndef NULL
  2.        #ifdef __cplusplus
  3.        #define NULL    0
  4.        #else
  5.        #define NULL    ((void *)0)
  6.        #endif
  7.        #endif
  8.  



-RajX
__________________________________________________
C++ Internals: http://www.avabodh.com/cxxin/cxx.html
Dec 9 '10 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
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.
Dec 9 '10 #4

Expert 100+
P: 2,396
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.
Dec 9 '10 #5

P: 3
Thanks to all for spending time to reply my question..
Dec 10 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.