Don't get me started on my problems...
Tim Holloway wrote:What's more important: did you resolve your problem?
Definitely. But would you define constant for the tab character '\t'? Or newline '\n'? Perhaps you would. But anyway, '\0' isn't any different to those - the number 0 isn't really a number in this context, it's just part of the 'symbol' for the NUL character.
Tim Holloway wrote:Still, I do recommend manifest constants rather than "magic numbers", no matter what syntax you use.
I'm curious to know where that world is, because it's obviously very different to the un-real world I've been (professionally) writing C in, start-ups and multi-nationals, for the past 30-odd years where I don't remember anyone ever using anything other than '\0' as a string terminator. That's a genuine question. And again if you can show me anything online that uses/advises something different I'd be interested - C specifically as that's mostly what I do. You learn something new every day
Tim Holloway wrote:You win . But as I said, in the real world, I've not seen it used.
Sorry - printed page 31.
John Matthews wrote:page 37 of The C Programming Language
I find that very hard to believe - it's basic stuff, page 37 of The C Programming Language
Tim Holloway wrote:I've never seen '\0' used as a NUL.
I think the intention is to set the whole buffer to the end of string character '\0', which is at least logically different to '\000' and correct in this context. But as I mentioned above unnecessary.
Tim Holloway wrote:If, as I presume, you mean for '\0' to stand for the octal byte value \000, I'd recommend that you follow common practice and write all 3 digits.