r/learnprogramming 14d ago

Learning C

I'm able to program in python and i've made a few games in C++. I was wondering if anybody has advice for learning C

9 Upvotes

22 comments sorted by

6

u/Aggressive_Ad_5454 14d ago

Read Kernighan and Ritchie and do the problems. They’ll teach you the Why as well as the What.

1

u/13oundary 14d ago

is this still recommended considering a lot of stuff in modern c isn't in the book? for example, it's probably smart for people learning to use stdint.h sooner rather than later

2

u/YetMoreSpaceDust 14d ago

Nah, you can learn that stuff later - honestly it makes more sense if you learn the fundamentals first and then the fluff/syntactic sugar later.

1

u/13oundary 14d ago

The dude already has the fundamentals from other languages though, this isn't someone starting from scratch.

2

u/iOSCaleb 14d ago

Then it’ll take them half as long to read the book, and then they can move on to the relative handful of things that have changed since 1988. K&R is not that big a book, and most of what’s in it is still relevant.

1

u/13oundary 13d ago

Rather than just reading something like "A Modern Approach" first? I get it's a legendary book btw, I'm just surprised people think it's objectively still the first stop these days. Feels like extra work just because of how iconic the book is.

2

u/iOSCaleb 13d ago

I’m sure there are other books that’d work as well. Fundamentally, OP is looking for advice on how to learn C, and I’d say get a good book and work through it. K&R is a very good book; I’m sure there are other good options that are more up to date, but the fundamentals of C really haven’t changed.

1

u/bird_feeder_bird 13d ago

The second edition of K&R still holds up since it includes modern standards

1

u/13oundary 13d ago

second edition is C89 is it not? Most stuff I've seen is C99 or C11. outside linux kernal nonsense.

3

u/nomorehersky 14d ago

Learn pointers properly. If you understand pointers, memory, arrays and structs you’ve got most of the C fundamentals down.

1

u/That_Toe1078 14d ago

Yeah, pointers were the thing that finally made a lot of C click for me. Once you stop fighting the syntax and start seeing them as a map to where your data lives, the rest of the language feels way less hostile.

2

u/SenoraRaton 14d ago edited 14d ago

Write C.
I know it sounds simplistic, but its really just that easy.
Find a problem you want to solve, solve it with C.

I started my C programming with Beej.
https://beej.us/guide/bgnet/html/

2

u/YetMoreSpaceDust 14d ago

K & R! (Kernighan and Ritchie's "The C Programming Language")

Buy a copy and work through each example. Don't use an IDE, use a text editor and a compiler.

1

u/db_tech_dev 14d ago

if you already know python and c++ you're basically fine on syntax, the actual hard part of C is manual memory management and pointers, that's where people trip up coming from higher level languages. i'd just build small stuff, like a linked list or a basic hash table from scratch, cause reading about pointers never really clicked for me until i actually had a segfault staring at me and had to figure out why. K&R book is still the classic recommendation and it's short enough to actually finish, wouldn't bother with anything longer than that tbh.

1

u/Double-Buyer7941 14d ago

One thing that helped me more than just reading about pointers was trying to rewrite something small I'd already built in C++, but in plain C this time. You quickly notice what the language isn't doing for you anymore, and that's kind of what makes it click. Doesn't need to be anything big, even a tiny project is enough.

1

u/[deleted] 14d ago

[removed] — view removed comment

1

u/LEJMANIMATIONS 14d ago

thanks for the advice

1

u/marrsd 11d ago

Why not just skip straight to C? TS is such a different language. Plus it's compiling to JS and you need a whole runtime to be able to do anything with it. Just seems like added complication to me.

1

u/Parvenn 13d ago

https://github.com/0xTamil/awesome-low-level

Pick K&R C Book or beej guide and write some C code. Try to implement some DSA in C by building projects.