5 ms·
Show HN: The Little Book of C
- omoikane 1y agoThere 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#example-copy-text-from-one-file-to-another 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#adding-another-layer 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.
- _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.
- tamnd 1y agoMy 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.
- reader9274 1y agoIf the "little" book is 461 pages, I can't wait to see the big book.
- taminka 1y agofr that's like the size of full C spec lol
- userbinator 1y agoFor comparison, the "gold standard" of K&R is roughly 200 pages.
- tamnd 1y agoI'm planning to create a 10-page cheatsheet for fast learners, and I'd like to shorten the book to around 150–200 pages.
- indianmouse 1y agoNice effort. Good to see 'C'!
- deleted 1y ago[deleted]
- user982 1y agoNobody finds it at all questionable that this submitter has "authored" around a dozen such books in 30 days?
- ForceBru 1y agoYeah, 15 different "Little books of..." here: https://github.com/orgs/little-book-of/repositories https://github.com/orgs/little-book-of/repositories. Seems LLM-assisted. This post about neural networks is from the "Math" book: https://news.ycombinator.com/item?id=45434678 https://news.ycombinator.com/item?id=45434678.
- teiferer 1y agoAnd many of them have the same "citation" to the math one by a Duc-Tam Nguyen, which they then didn't bother to adjust the title of. I'd vote for flagging this submission. It's just AI slop.
- teiferer 1y agoI wonder if those LICENSE files in such repositories even mean anything in the world of LLM created stuff/slop/crap. There is no obvious authorship attached to this "Little book" which is a tell-tale sign since anybody investing time into actually writing such a book would surely like to claim authorship.
- tamnd 1y agoSo you assume that writing those books takes little time? Just some "prompt magic," and boom, a book appears?
- teiferer 1y agoYes, that's what I think. Considering the number of "little books" you (assuming it was you) published in the last weeks, it's a reasonable view, don't you think?
- tamnd 1y ago
- chrisbrandow 1y agoThis reads like one of the clearest intros to C that I have seen in a long time. Feels approachable the whole way through.
- tamnd 1y agoThanks for your kind words! They really encourage me to share more. Please be aware that there might still be some bugs, so feel free to create issues or pull requests!
- jmclnx 1y agoI do not get this ? Why is this flagged ? I agree in flagging in the cases I have seen, but flagging a C book seems very odd.
- tamnd 1y agoBecause of some LLM editing and the help of "AI policies," some people call this book "AI slop." I admit that I used an LLM for editing, and this book still needs heavy editing and a thorough review to fix all the bugs in the code. But I wanted to share it early to see if anyone is still interested in C before I move on to reviewing the list of exercises and preparing for several upcoming projects: building a search engine, a vector database, and a columnar database from scratch in C. This book is open source, open for contributions, and completely free of charge, and anyone with a GitHub account can contribute.