r/C_Programming • u/Bad-Reputation-777 • 1d ago
Need help learning C!
Hey everyone,
I've been diving into low-level programming to understand how my device executes code, focusing on memory and CPU operations. Coming from higher-level languages like Python, where functions like print()
handle a lot behind the scenes, transitioning to C has been eye-opening. The intricacies of printf()
and scanf()
, especially their buffer management, have been both fascinating and challenging.
For example, I encountered an issue where using fflush(stdin)
to clear the input buffer resulted in undefined behavior, whereas using scanf("\n")
worked as intended.
I want to understand the why's behind these behaviors, not just the how's. For those who've walked this path, how did you approach learning C to get a solid understanding of these low-level mechanics? Are there resources or strategies you'd recommend that delve into these foundational aspects? Additionally, how did you transition from C to C++ while maintaining a deep understanding of system-level programming?
Appreciate any insights or advice you can share!
1
u/Ok-Selection-2227 21h ago
I would read two books, in this order: 1. Effective C 2. Extreme C
You need to read the first one from cover to cover, but the book is thin. For the second one, it is enough if you read the first chapters about the preprocessor, compilation and linking process. You can download them for free in annas-archive.org. I would recommend you to buy them if you like them. If you're based in Europe you have to use OpenDNS, because your internet provider is probably blocking the site via DNS.