zero

Is 0 a decimal literal or an octal literal?

孤者浪人 提交于 2019-11-26 02:28:44
问题 Zero is always zero, so it doesn\'t matter. But in a recent discussion with a friend he said that octal literals are almost unused today. † Then it dawned upon me that actually almost all integer literals in my code are octal, namely 0 . Is 0 an octal literal according to the C++ grammar? What does the standard say? † The only real use I\'m aware of is for unix file permissions. 回答1: Yes, 0 is an Octal literal in C++. As per the C++ Standard: 2.14.2 Integer literals [lex.icon] integer-literal

Is NULL always zero in C?

*爱你&永不变心* 提交于 2019-11-26 01:45:47
问题 I was interviewing a guy for a mid-level software engineering position yesterday, and he mentioned that in C, NULL is not always zero and that he had seen implementations of C where NULL is not zero. I find this highly suspect, but I want to be sure. Anyone know if he is right? (Responses will not affect my judgement on this candidate, I\'ve already submitted my decision to my manager.) 回答1: I'm assuming you mean the null pointer. It is guaranteed to compare equal to 0 . 1 But it doesn't have