

Beginning to learn C: What resources should I be using? - arclighter

Title may be misleading; I&#x27;ve already started.<p>First I was 10 years old (or so) and my father tried (with some success) to teach me to program in C. ~5 years later, and after learning Python, I&#x27;ve decided to give it another try. So I joined ##c on Freenode and was given the direction to go study K&amp;R and avoid a specific set of other books (Learn C The Hard Way, Learn C in 21 Days).<p>So... I followed that advice. I&#x27;ve spent most of the last 2 days trying to absorb as much as I can about C, and what I&#x27;ve found is that while it feels like coming home in a way, there are some significant differences in the C I first learned to write and the C in K&amp;R.<p>Examples:<p>I write &#x27;int main()&#x27;, K&amp;R writes &#x27;main()&#x27;<p>I write &#x27;return 0;&#x27; at the end of the main loop, K&amp;R does not.<p>I encapsulate everything (if, while, for, etc) with brackets, K&amp;R often does not use brackets at all. I&#x27;m not sure why.<p>After noting this, I decided to find out why these differences were there. And apparently, K&amp;R, the resource everyone told me to use to the exclusion of all others, is almost universally considered outdated. Though I know that C is an old language, I want to learn it as it&#x27;s used in the present day.<p>What should I actually be learning from? And who should I trust? Honestly, I feel slightly betrayed.
======
ThatGeoGuy
C is a language that has come a long way since the original K&R. And quite
frankly, K&R is a good source to get the feel of C, but it doesn't really
reflect how C is used in practice today. That said, I've found "Modern C" by
Jens Gustedt [1] to be very good at teaching the basics of the language up to
the intermediate level.

At some point though, you need to study projects and other various tools in
order to get a better understanding of how C is used and how to write more
advanced C code. Things like valgrind, gdb, strace, etc become more and more
important, and eventually you'll find that most of the techniques you use in
other languages are just represented differently in C (such as OOP).

Good luck, and honestly, don't force yourself to learn it if you don't feel
you need to. You're young enough that you'll learn it eventually if you really
need it.

[1] [http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf](http://icube-
icps.unistra.fr/img_auth.php/d/db/ModernC.pdf)

~~~
arclighter
Thanks for the link.

------
CyberFonic
I too learnt C from K&R. It is good for coming to grips with the language.
Coming from Python, you might have to come to grips with pointers, typedefs,
structs, etc.

Once you have the basics sorted, the real learning comes from reading some
open source project. There are lot of conventions and patterns in use. They
are dictated by the compiler (and other tools) being used and the project's
conventions.

Personally I learnt a great deal from studying Unix kernel sources from the
John Lions books. A more modern equivalent is "Linux Core Kernel Commentary".

Once you read up on different open source projects, you will see that there is
_no one way_ of using C.

------
dllthomas
I learned from "A Book on C", and for a long time found it a good reference,
and it's usually what I recommend to others. Finding someone to talk to and
projects to work on is probably more important than reading material, though.

