In K&R2, the declarations and initializations of everything are separated. Also, when NULL is introduced, not once is it used in an initialization, but always as a return or comparison value.
Did the practice emerge subsequently, or did the writers think their way was adequate?
Not the case. In the section on Declarations (section 2.4, page 40), you will read:
Various examples follow.
There is nothing special about
NULL; it's just a value which may be assigned to a pointer variable.Many people believe that it is a good idea to always provide an initialiser, because if you don't, you run the risk of using an uninitialised variable. On the other hand, that practice does not really fix bugs. Erroneously using an arbitrary initial value might prevent undefined behaviour, but it is still an erroneous value, and you would arguably have been better off seeing the compiler warning about possible use of an uninitialised variable. (Always enable compiler warnings.)
At any rate, if you feel the need to initialise a pointer variable,
NULLis a convenient option. Sometimes it is even the correct option.By the way, you'll find an example of initialising to
NULLat the top of page 187: