Re:Teaching C
by bogomipz on Wednesday May 11, 2016 @02:11AM
(#11672954)
Why do some people store chars to store numbers?
[ Parent
| on HN ]
Because unlike other programming languages C didn't define a type called byte, so developers were forced to use char for what is byte in saner systems programming languages.
With the caveat that unless you precede them with signed/unsigned modifiers, it is not portable.
Because uint8_t is comparatively new. C99, IIRC, though many OSes defined their own earlier.
They need a char-sized number, and memory used to be a tightly-budgeted commodity.
Reminds me of this story of a game developer who magically got their game under the limit at the 11th hour
http://www.dodgycoder.net/2012/02/coding-tricks-of-game-deve...
Re:Teaching C
by Kristine1975 on Wednesday May 11, 2016 @02:58AM
(#11673131)
Although char should not be used to store numbers, since its signedness is implementation-defined (gcc has the switch -funsigned-chars I think to make them unsigned instead of signed). signed char/unsigned char are ok.