Re:Everything I wish I knew when learning C
by tmewett on Monday November 28, 2022 @10:35AM
(#33774856)
Interesting, I didn't fully realise that. That it's arbitrary is annoying, I clearly had tried to rationalise it to myself! Thanks for the comments, will get around to amending
[ Parent
| on HN ]
Re:Everything I wish I knew when learning C
by emmelaich on Monday November 28, 2022 @07:08PM
(#33781771)
Hi, great article. Regarding char, I'd remark that getchar() etc return int so it can return -1 for EOF or error.
I'm pretty sure this implies int as a declaration is always signed, but tbh I'm not completely sure!
Re:Everything I wish I knew when learning C
by yakubin on Monday November 28, 2022 @07:36PM
(#33782041)
int, as all other integer types except char, is indeed signed by default.
Aside: signedness semantics of char is implementation-defined. However, the type char itself is always distinct from both signed char and unsigned char.