News for hackers. Stuff that matters.
Re:C Strings and my slow descent to madness by PaulDavisThe1st on Saturday April 08, 2023 @12:34AM (#35490562)
Well that's pretty fucked up. I note that the GNU C library docs say this:

> Attention: In versions of the GNU C Library prior to 2.1 the return value is the number of characters stored, not including the terminating null; unless there was not enough space in s to store the result in which case -1 is returned. This was changed in order to comply with the ISO C99 standard.

ISO C99 needs a kick in the head. Yes, there is a use case for this return value (buffer wasn't large enough, reallocate and try it again). But wow, own goal team!

Thanks for this. I had no idea that C99 had defined this so stupidly.

There are no comments on this comment yet.