Comment by omoikane

9 days ago

There is a bug in this example:

    char ch;
    while ((ch = fgetc(in)) != EOF) {
        fputc(ch, out);
    }

https://little-book-of.github.io/c/books/en-US/book.html#exa...

The return type of fgetc() is `int` and not `char`. This example will not differentiate between end-of-file in input versus reading 0xff. 82.7 appears to be the only example with this issue, all other places with fgetc correctly uses `int`.

----

I found another section with lots of syntax errors, for example:

    int x = 10;
    int *p = &x;
    int pp = &p;   // Should be int **pp

https://little-book-of.github.io/c/books/en-US/book.html#add...

Most likely because the two asterisks needed for pointer-to-pointer isn't rendering properly.

> 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.

My next step is to extract all the code into the "src/" folder and set up proper CI/CD to test everything.

Could you help create some GitHub issues? I will fix them in my free time next weekend.