I haven't read these 2 books, but would like the opinion of someone who did. [1] C Interfaces and Implementations: Techniques for Creating Reusable Software by David Hanson - HN's tptacek seemed to rave about this book, that's how I heard of it. Wonder what he thinks of it in 2021. [2] C Programming: A Modern Approach by K. N. King - this one seems to be loved by many. Seems to be more 'beginner-friendly' than the 1s…
Beej’s Guide to C Programming [pdf]
171–178 of 178 posts
Re: Beej’s Guide to C Programming [pdf]
#172I haven't read these 2 books, but would like the opinion of someone who did. [1] C Interfaces and Implementations: Techniques for Creating Reusable Software by David Hanson - HN's tptacek seemed to rave about this book, that's how I heard of it. Wonder what he thinks of it in 2021. [2] C Programming: A Modern Approach by K. N. King - this one seems to be loved by many. Seems to be more 'beginner-friendly' than the 1s…
It remains my favorite C book, though: I don't think you should write much C anymore.
Re: Beej’s Guide to C Programming [pdf]
#173Earlier quoted context omitted.
While experienced C programmers that care about security wouldn't even touch strcpy() . All those code samples will crash and burn if s and t point to the wrong locations, t happens to point to a string without a null terminator, or s points to a buffer not big enough to handle the string pointed by t.
> All those code samples will crash and burn if s and t point to the wrong locations This is true for all uses of pointers in C. The only validation you can do is whether a pointer is null. Apart from that you can never know that a pointer points to a non-wrong location. And still experienced C programmers seem to be OK with using pointers.
But even then, most experienced C programmers don't care about using them anyway, that is why Apple, Oracle, Microsoft, ARM, Google, Cambridge university are all leading efforts for hardware memory tagging.
So it won't matter how much they care, as the OS will kill their beloved application when pointers get misused.
A scenario already made reality in platforms like Solaris SPARC.
Re: Beej’s Guide to C Programming [pdf]
#174Earlier quoted context omitted.
For anyone who wants to learn about pointers I can recommend studying a language simpler than C like for instance Oberon where pointers are more restricted. Having a look at Oberon can also broaden your view even if you know pointers in C. https://www.miasap.se/obnc/oberon-report.html http://people.inf.ethz.ch/wirth/Oberon/PIO.pdf
Actually, this could confuse things even more, because the C pointer and Oberon's POINTER TO have very little in common.
Re: Beej’s Guide to C Programming [pdf]
#175Earlier quoted context omitted.
Just wanted to say THANK YOU as I read your guide to network programming way back in 2000, over 20 years ago! I was just starting out in C network programming on VxWorks :) Glad to see you're still updating your guides.
Thanks! Makes my day to hear people find the work useful. :)
Re: Beej’s Guide to C Programming [pdf]
#176Earlier quoted context omitted.
> All those code samples will crash and burn if s and t point to the wrong locations This is true for all uses of pointers in C. The only validation you can do is whether a pointer is null. Apart from that you can never know that a pointer points to a non-wrong location. And still experienced C programmers seem to be OK with using pointers.
Actually no, many OSes do have APIs to validate pointer integrity. But even then, most experienced C programmers don't care about using them anyway, that is why Apple, Oracle, Microsoft, ARM, Google, Cambridge university are all leading efforts for hardware memory tagging. So it won't matter how much they care, as the OS will kill their beloved application when pointers get misused. A scenario already made reality in…
Are outside the scope of the C language. But if you allow these special APIs, you can use them to implement a safe strcpy. Either way your point from above is still invalid.
Re: Beej’s Guide to C Programming [pdf]
#177Again, the string chapter is telling us about zero-terminated char arrays/pointers and doesn't even mention Unicode/UTF-8 or safety :-(
I do have a chapter on Unicode and wide characters, but it's separate from the "classic" strings chapter. That said, I could certainly refer forward to it. And C11 only has minimal portable UTF-8 support, but I do talk about it. I think C21 will improve on that a bit. A note on safety would be well worth it. I'll do that. Good suggestion.
Re: Beej’s Guide to C Programming [pdf]
#178Earlier quoted context omitted.
It remains my favorite C book, though: I don't think you should write much C anymore.
My favorite is Expert C Programming: Deep C Secrets by Peter van der Linden. I started it as soon as I encountered C at university and could only get through about a chapter at a time. By third year when the assignments in C got hard I was in a great position, partly for this book. Even crazier is I enjoyed it.