I was going to write a rant to explain the reasons why I don't like it... but I am getting extremely sleepy so I'll just say it annoys me and I wish people wouldn't do it.
If you want to assign the integral value of 0, just assign 0. Don't assign a character with an escaped octal value of 0. That's just absurd.
Are you the kind of person who would use 0 instead of NULL?
Considering NULL is a macro... yes... absolutely.
Though I do use nullptr when null'ing pointers. Though I don't null pointers very often.
Catfish3 wrote:
We don't have a nullchr thing, so some of us will use the next best thing, '\0'
The only time that would make sense is if you have to differentiate between int and char versions of function overloads/templates based on the parameter.
But in the case of templates, I would rather just explicitly name the type in the template params rather than use '\0'. And if you have a function overload whose only difference is char vs. int (and their behavior isn't interchangable).... then your code has bigger problems.
Zhuge wrote:
For C++, MSDN lists \0 as a special escape sequence (not just 0 in octal), as does cppreference.com.
That's retarded. It isn't a special escape sequence. It's just a common octal escape sequence.
I can all but guarantee that no compiler anywhere treats it as a special escape sequence.
This is actually why this is such a pet peeve of mine. It's taught to be some kind of special escape sequence when it's not.
For Windows compilers and Windows headers, NULL is only defined in Windows.h, and not including Windows.h means that NULL is never defined (not even in any of the C/C++ standard library headers). That's how messed up Windows compilers are.
@Catfish3 MSVC, and it doesn't compile in my build environment.
That's not the only thing - the <c*****> headers don't even wrap anything in the std:: namespace like the standard mandates. There's macro guards for if you wanted to disable putting them in the std namespace, but they're pointless because they guard nothing (literally just blank lines between them).