Handmade Hero»Forums»Code
Philip Ludington
14 posts
(tbd)
Learning C, Again
Edited by Philip Ludington on
I'm jumping back into C, last time was I used C was in the 90's. I started with this website http://c.learncodethehardway.org/book/ and so far I like it's approach, especially the "Break It" sections But, I came across this book C Programming: A Modern Approach, 2nd Edition http://amzn.com/0393979504 It's got great reviews, but also really expensive, $113!! Anyone have any opinions on either? I'm a professional developer, mainly C# and Unity, so I don't need a beginners book/website.
4 posts
Learning C, Again
Edited by Drexir on
"learn c the hard way" well doesn't teach you anything. If anything I'd say it will just end up confusing the learner more than anything. Not to mention the book has quiet a few errors.

A modern approach is a good book. For the price tag; it's used in schools as a textbook hence the higher price. Seems a bit backwards how that works. Anyways K&R C is not a bad book at all. It may trip up the absolute beginner because it uses the ANSI C standard. Which didn't require you to specify a return type for main. Also you could only declare variables at the beginning of a function. And a few other things. Otherwise it's still relevant. And a good read.
Ginger Bill
222 posts / 3 projects
I am ginger thus have no soul.
Learning C, Again
Edited by Ginger Bill on
"Learn C The Hard Way" is dreadful. I would suggest The books:

  • -- The C Programming Language (K&R) ("The Bible")
  • -- C Primer Plus

Because there are not many great resources out there for learning C (especially for beginners), I have started a new series called Intro to C. It's a video series that teaches everything about C for complete beginners. If you are not a beginner, I would suggest just reading some books.

In C, the most difficult thing to learn in my opinion is pointers. I remember when I was learning C years ago, the concept of pointers took over a week for me to actually understand.

The other difficult thing is if you are coming from C# is unlearning OOP. C is mainly a procedural language. In my opinion, most implementations OOP are dreadful and actually hinder "code reuse" (from experience). The only language that I have personally used that uses a kind of uses OOP that I "like" is Go (even then, most people say it isn't even a "true" OO language but that's mainly people it doesn't do encapsulation at a local level and "true" inheritance, etc.). In most of my Go code at work, I think I have written 5 methods (hundreds of standalone functions though). That's it. In Go, the OO way is only useful certain things such as file systems.
511 posts
Learning C, Again
Find the specification of the version you are using.

There have been several and they are not all compatible. And for any tutorial/book you follow you need to know which version they are targeting.
Ginger Bill
222 posts / 3 projects
I am ginger thus have no soul.
Learning C, Again
I would suggest learning C99 as this is supported by most compilers (and now MSVC 14+ (except VLAs)). The later version C11, adds a few things but not anything that is drastically different nor difficult to learn if you know C99.

I would suggest not learning C89/C90/Ansi-C/Hardcore-C and stay away from the GNU variants too.
Bryan Taylor
55 posts
Learning C, Again
I don't get the hate for Learn C The Hard Way. It's fine.

I wouldn't buy a book to learn C, though -- there's not a whole lot of need. C itself is actually a *very* small language, much smaller than C# or Java or Python.

Learn the basic syntax, and then start writing a lot of C. Personally, I worked through all of DSA ( http://dotnetslackers.com/projects/Data-Structures-And-Algorithms/ ), implementing everything as I went along, which was enough to help me "get" pointers. If you run into any tools/utilities you'd usually use C# for, write them in C instead.

Find a good reference for the stdlib. I use http://linux.die.net/man/3/ for *nix, and MSDN for Windows. There are, of course, plenty of others.

Write lots and lots and lots of C. Practice is more useful than any book. You can worry about the details of the One True Way of Writing C *after* you can use C proficiently.
Ginger Bill
222 posts / 3 projects
I am ginger thus have no soul.
Learning C, Again
Here is an article that I mainly agree on with why "Learn C the Hard Way" is bad: http://hentenaar.com/dont-learn-c-the-wrong-way
Philip Ludington
14 posts
(tbd)
Learning C, Again
Edited by Philip Ludington on
Thanks for all the thoughts! Since Learn C the Hard Way is free, I think I'll just finish it and then see what feels missing. I get pointers, just need to relearn some of the nuances.


btaylor2401
Personally, I worked through all of DSA ( http://dotnetslackers.com/projects/Data-Structures-And-Algorithms/ ), implementing everything as I went along, which was enough to help me "get" pointers. If you run into any tools/utilities you'd usually use C# for, write them in C instead.


This looks like a great resource, thanks!


btaylor2401

Write lots and lots and lots of C. Practice is more useful than any book. You can worry about the details of the One True Way of Writing C *after* you can use C proficiently.

Totally agree.
Carsten Holtkamp
26 posts
Learning C, Again
I wouldn't spend so much money on such a general book.
The book isn't a rocket science break through paper, it is just an ordinary book from 2008.
Ofc it doesn’t cover C11, cause it is from 2008.

You can buy a lot of used books really cheap.

Here you can find a lot of PDF’s
http://it-ebooks.info/

Here a search for c language
https://goo.gl/UQJmJ6

I have NO CLUE if this page is legal, it is around since 2011 now.

Site states:
Reproduction of site books is authorized only for informative purposes and strictly for personal, private use.
Ginger Bill
222 posts / 3 projects
I am ginger thus have no soul.
Learning C, Again
Edited by Ginger Bill on
I am guessing that the site is illegal but I could be wrong as I am not a lawyer and different countries have different laws. The "Head First C" book on that site is not a book for a beginners but for people who already know a language and depending on your learning style. The book also gives a go at humour (which you may or may not like).

C is very simple language but from its simplicity, it brings allows for a lot of complexity.
Carsten Holtkamp
26 posts
Learning C, Again
Another free C-language book:
http://publications.gbdirect.co.uk/c_book/

Maybe we could maintain a book-list with reviews?
Mattie
35 posts
Learning C, Again
Stack Overflow has a list of books, categorized by skill level: http://stackoverflow.com/a/562377/1486690
Piotr Madalinski
9 posts
Learning C, Again
I've found reading the linux kernel source code very instructive.
It's a very well engineered codebase - simple, down to earth, and yet uses a few C specific tricks and idioms (and macros) which are worth knowing.

The only problem is to figure out where to start (myself - I was trying to modify a driver for my router, so it wasn't an issue).

Maybe pick a simple subsystem (like gpio) and give it a shot:
http://lxr.free-electrons.com/source/
Carsten Holtkamp
26 posts
Learning C, Again
Great, don't think I stumbled over it.
I have a way more comprehensive private list,
with distinct application fields or Host environment.

Like:

*GPU-Computing:Professional CUDA C Programming
or
Black Art of 3D Game Programming: Writing Your Own High-Speed 3D Polygon Video Games in C, Andre Lamothe, Sep 1995

Lately I saw tons of "new C books" where a guy created a script to swizzle topics and release/sell 15 instead of one book :(
Misu Popescu
6 posts
Learning C, Again
Edited by Misu Popescu on
@MrPhil

You can buy C Programming a modern approach by King at half a price from abebooks.com. Pretty sure you can get it at an even better price if you do some research. Also, if you know a student at a decent Uni you may ask him to borrow the book for you if you just want to have a look.

Learn C the hard way - is not a bad book, keep in mind that the author has also released a series of videos, one video for every book chapter. The author has strong opinions about how to code in C, but you can say the same about our own gingerBill here :).