Closed cahan0506 closed 1 year ago
Do you get a specific error/warning here?
I don't see a problem, except for a few compatibility warnings. Part of the issue is we don't have the original compiler and so many things have changed even between the 1st and 2nd editions. The same code is different.
There are many online versions of this code but it's all been updated for different systems and compilers it might not work anymore, so it's an example now.
For example in the 1st edition, pg 167
fp->_flag |= (*mode == 'r') ? _READ : _WRITE;
is now
fp->_flag = (*mode == 'r') ? _READ : _WRITE;
in the 2nd edition, the |=
changed to =
.
This statement looks fine. The "block" is the if statement on the following line. The authors tend not to put curly braces in unless there is more than one statement in the block. For those of us - modern style guide suggestions usually tell us to add the curly braces - any time a statement is on a new line - but this is not required in the language.
From Github: https://github.com/csev/cc4e/blob/master/book/code/c_167_01.c
From https://techiedelight.com/tools/clike
I thought only the next two lines "if ... break" had something to do with the for statement.
https://www.cc4e.com/book/pages/page_167
To my eyes there is an indention conflict between the PDF page and the github code. I assume the logic is OK.
What about Appendix A?
I found errata for 2. edition but I am sure that you already know about the page :-) https://www.cs.princeton.edu/~bwk/cbook.html
You are quite right - do you want me to fix it or do you want to send a pull request and get credit?
I just have not done Appendix A yet - I did not think it was significant.
Closing via PR #44 - Thanks!
The FOR-statement is not a complete block.
Appendix A seems to be missing.
I read the book with great pleasure :-)