3 ms·
> The return type of fgetc() is `int` and not `char`. This example will not differentiate between end-of-file in input versus reading 0xff Be aware that charac
by _zagj 1y ago
> The return type of fgetc() is `int` and not `char`. This example will not differentiate between end-of-file in input versus reading 0xff
Be aware that character literals in c, e.g., 'f' or 'A', have type int for probably this reason. From the ANSI C89 spec:
> An integer character constant has type int. The value of an
integer character constant containing a single character that maps
into a member of the basic execution character set is the numerical
value of the representation of the mapped character interpreted as an
integer.
However, in C++, they have type char.
- tamnd 1y agoI have fixed some bugs here: https://github.com/little-book-of/c/pull/4 https://github.com/little-book-of/c/pull/4 Let me carefully review all the code snippets, create tests, and integrate them into the CI/CD pipeline to make sure everything is correct.