3

What is the difference from NULL and "0"?

Example:

return NULL;
return 0;
Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Steven Hammons
  • 1,774
  • 8
  • 24
  • 33

1 Answers1

12

Conceptually, zero (0) is a number, and NULL is a value that represents "no value". As such, 0 can be added, subtracted, etc., but NULL cannot. The NULL value for a variable can indicate, for example, that a variable has not yet been assigned a value.

The semantics of NULL may vary by language or application.

Glenn
  • 6,455
  • 4
  • 33
  • 42