3 ms·
Yep, that's what I meant by plenty of facepalms to go around. The entire class of functions is "unsafe at any speed." Code which seems perfectly safe on one c
by CamperBob2 5y ago
Yep, that's what I meant by plenty of facepalms to go around. The entire class of functions is "unsafe at any speed." Code which seems perfectly safe on one compiler will blow up on another, literally without warning.
I do wonder why they didn't have the function take an unsigned int, or at least do a simple bitwise AND with 0xFF before the table lookup.
- radiospiel 5y agoBecause of EOF being -1
- Someone 5y agoNitpick: it is only guaranteed to be unequal to any character and less than zero. (And no, I don’t know any implementation that has it unequal to minus one. I would love to see a devilish C compiler/standard library that would make all kind of standard-conforming, yet non-standard implementation choices (EOF not minus one, RAND_MAX a fairly small prime, etc. Goal would be to have no single major program run correctly on it)
- CamperBob2 5y agoGood point, but if the standard defines EOF as a negative value while at the same time permitting implementations to support default-unsigned char types, then the sanity train obviously left the tracks at that time, or at some time prior to it.