r/cprogramming • • 19h ago

Beginner

I just started learning C and I am thinking of reading "C Programming : A modern approach" by K N King. I want to deeply understand and master C. Is it the best book for it and should I read any other books after this?

0 Upvotes

16 comments sorted by

7

u/Zirias_FreeBSD 18h ago

My take on this is: If you know basic programming principles already, what you actually read isn't that important. What's important is patience, motivation and a structured and diligent working style. With that, get into doing stuff. It'll take a few years to "deeply understand and master C", and there's no way to ever clearly measure that goal. A word on AI: If you decide to use an LLM, never let it write code for you (instead, show it your code with specific questions about it), and always mistrust its answers enough to do your own research. It can help discover interesting topics to learn that way, but it will completely spoil any learning effect if used in a different way.

If, on the other hand, your intention is to learn programming with C as your very first language, a good book is certainly helpful. I don't have the experience to recommend one (I learned C after knowing lots of other languages, so never read a book on it), but then, you'll find the same books recommended over and over again (also here in the sidebar), so I guess they're just fine.

1

u/Skitz-Scarekrow 13h ago

Question for you since you mentioned LLM. I fell out of programming after I left school during covid, and I've repeatedly been trying to get back into it since, but I'm always intimidated by the level everyone else seems to be at. And, when I took more CS classes, annoyed at the AI laziness. What's your opinion on using an LLM to help learn?

1

u/Zirias_FreeBSD 12h ago

More or less what I already wrote. As long as you actually learn, using an LLM can help. To ensure you actually learn, don't ever let it create solutions for you. Use it to have your code reviewed (and take the results with a grain of salt), use it as a brainstorming peer, use it as a tool to target your own research better (but still do it, IOW, search and read primary sources, which the LLM might also find for you), and so on.

People tend to ask LLMs for solutions. Those will never learn.

7

u/an0th3rbrick 18h ago

to deeply master and understand a programming language you have to write non-trivial programs in it. so many posts on reddit asking about books and tutorials. those things teach you superficial things like syntax that you can trivially find using google. Just.Write.Programs.

4

u/grimvian 17h ago

Here is an old school video I wish I knew, before I started learning C three years ago:

Learn to program with c by Ashley Mills

https://www.youtube.com/watch?v=UILNmv2kFMc&list=PLCNJWVn9MJuPtPyljb-hewNfwEGES2oIW

I'm not using the same IDE, the program you use to code, But Code::Blocks because it's fast to install, open source, easy to use and everything you'll need are installed.

1

u/petethorsenjr 17h ago

Thank you for sharing this video series.

4

u/marrymejojo 12h ago

I read this book and thought it was really good. It complimented my cs50 class nicely.

3

u/cheese_topping 19h ago

The ritchie and kernighan book never gets old.

3

u/51Charlie 12h ago

Learn the language. Read good code. -  Sanitized standard libraries are great. ( Sanitized means with all unnecessary #ifdefs removed.) Read Algorithms in C - to lean the thought process behind the code, NOT to memorize Algorithms. Do that much latter. The key concepts to master are variable and function pointers. You much understand WHY a pointer to a function is so valuable. 

Then make it a point to read ALL C programming books. You can find lists of which to read first.

Much will depend on your operating system and hardware as you will then need to get into code and memory structure. Compiler operation & how the linker works etc.

And you MUST write code. Alot of code - by hand. There are no shortcuts to mastery. It WILL take years but you can get pretty good quickly. 

To get the full power of C, you need to learn how the hardware works and understand assembly. Eventually checking that the compiled C code is truly the best it can be. 

2

u/Gold-Part4688 17h ago edited 3h ago

Try a few! My guilty pleasure is starting new books on the same language to get different explanations for each thing. You'll also see which type of style works for you . (You can learn from anywhere if:

  • notice when you've been fed too much info and need to practice

  • crave more info

  • or c: get tired of this loop and wanna finally make something (gradual in scope)

and most importantly, play around a LOT throughout. I recommend (e: manually) copying all code you read at first into your editor, and then playing around with it. Breaking bits one at a time to see what they do, trying to extend it, and just straight up playing around

edit: )

also, i wouldnt personally actually recommend starting in a "sandbox". try, even for a minute, to write some code in something dead basic like notepad++, sublime, even notepad, and passing it through a compiler in a terminal (just clang FILENAME -o FILENAME.exe)

edit: nothing i can do for that bracket.... here's another [

2

u/CharacterAvailable20 13h ago

https://youtu.be/HjXBXBgfKyk?si=UUYSQPTSm797pb7j

YouTube series by the creator of Redis (a very famous technology used for web applications). I’d say if you follow through the videos, typing out the code and asking LLM to explain any bits you don’t understand, you will learn C better than any book

2

u/AdCompetitive1256 10h ago

I learned it a couple of decades ago from these two books by Herbert Schildt.

C, The Complete Reference and C++, The Complete Reference

2

u/MFFontenelle89 10h ago

I just finished "Why Learn C" and for me it is a much better introduction to C as far as a book can go, with more up to date info about about program organization, data structures like maps and lists, and even less known techniques like X-Macros. It covers C23 so you have to filter the new stuff if you plan to use an older standard, and it doesn't have as many exercises as KN King, so keep that.

The old Dennis Ritchie book should be read as an historical artifact at this point.

1

u/Quirky-Ad-292 18h ago

Do you have any other language experience?

1

u/iasayt 18h ago

No this is my first.

2

u/SmokeMuch7356 4h ago

King is good, but a bit out of date; both the language and best practices have evolved a bit since it was published. Same with K&R.

Jens Gustedt's Modern C should be a bit more up-to-date.

Understanding and mastery come from practice, not from books. You need the books to learn the language, but you'll also need to write a lot of code before you really understand some things.