Hacker News new | past | comments | ask | show | jobs | submit login

What's the best way to learn C? Any good modern book recommendations, or sites?



I second "Modern C" by Jen Gustedt.

- Get the `cdecl` tool to build intuition about function signatures. What does "int( * ( *foo)(void))[3]" mean?

- Write it yourself.

- Be disciplined. Develop good hygiene with compiler flags, memory/address checks, and even fuzzing.

- Read good source code such as the linux kernel. This is an amusing header file from the git source code that defines some banned functions. This is wisdom if you choose to follow it: https://github.com/git/git/blob/master/banned.h

- Push the language to its limits. Play with memory and data structures. Inspect everything. This book "Data-Oriented Design" by Richard Fabien is a great to explore as well. It's about organizing your data for efficient processing.


There's a second edition of the legendary K&R book¹ to get you started.

¹https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...


See my previous comment, anyone learning C from K&R should not be writing C period.

That book is legendary only in the magnitude of financial damages it (directly and indirectly) enabled, caused by people who read it and thought that they could now write C.


I highly recommend Zed Shaw's "Learn C the Hard Way": https://learncodethehardway.org/c/

I worked through this and felt well-prepared to actually use C in anger when I had to.


Terrible overall and entirely wrong in multiple places. If you learn C from this book, you should't be writing C.

The last bit is also true for K&R The C Programming Language (avoid at all costs).

You're better off with:

- Modern C (whatever edition is current)

- Seacord's Effective C: Introduction to professional C programming

- C Programming: Modern Approach 2nd edition (bible)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: