I agree, of course you can. You have to be able to allocate pointer for NULL pointers, because of the simple concept of the "initialize your variables before you attempt to use them" mantra.
All a NULL pointer is is a variable whose value has been set to nothing. It's like initializing an int to 0 first.
Quzah.
Hope is the first step on the road to disappointment.
6 in one, half a dozen in the other...
Both ways have advantages & disadvantages.
I would assume that if someone did find a discrepancy as you mentioned, they would fix it so the next reader doesn't have to go through the same head scratching motion. In 10 years I've never seen anyone try to assign NULL to a non-pointer. So I would say it's an extremely remote possibility.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
That's right, which is why I think it boils down to personal choice. In C++ we can wait for nullptr, but I am afraid there is no good solution coming up for C.Originally Posted by cpjust
I have done it myself when using some of those crazy programming interfaces with an excessive number of parameters, some of which are pointers while others are not. It is arguably a problem with the interface, but in such cases it does not matter whether the reader sees a NULL or a 0: he/she has to double check anyway.Originally Posted by cpjust
Last edited by laserlight; 04-27-2009 at 10:16 PM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)