Best book for a beginner to learn C?
May 21, 2008 10:44 PM   Subscribe

Best book for a beginner to learn C? I've never learned a programming language, but I'm hoping to learn C over the summer. My friend, a computer science student, is going to teach me as he learns it. We would like a textbook or reference book or work book of some kind. What would be a good choice?

I've heard the K and R 'C Programming Language' is considered the 'bible' of C programming, but I am wondering if this would be an appropriate choice for a beginner.
Things to bear in mind:
1) my friend will be creating 'lessons' from whatever book we choose. We'd like it to be thorough and start from the basics, but density is not necessarily an issue. That said, I'd like the text to be readable for both of us.
2) Although I have never programmed anything before, when I was younger, I dabbled in a bit of Flash so I'm reasonably ok with computers, and I have some background in math and logic. I don't know if this will help.

Thanks for your recommendations.
posted by asparagrass to Computers & Internet (22 answers total) 22 users marked this as a favorite
 
I'm pretty sure I used Kochan's book to learn C when I was 15 or so: Programming in C. I have a much older edition but I am pretty sure it is a classic. As one Amazon reviewer noted, it was written in '83 but the current edition was revised in 2004, although it's not like C has changed a lot in 25 years.
posted by GuyZero at 10:55 PM on May 21, 2008


K&R is pretty much the canonical book on C.
posted by pwicks at 11:05 PM on May 21, 2008 [2 favorites]


K&R is ancient history, akin to Chaucer in the scheme of things.

I was going to object to taking up C as a first language, but upon further thought C99 isn't that bad of a sandbox to play in, compared to its offshoots: Java, C#, JavaScript, PHP5, plus: Perl, Python, Ruby, processing, etc.

So my advice is to find a good C99 introduction and some programming tasks you're interested in.
posted by tachikaze at 11:08 PM on May 21, 2008


Get K&R!

1) Each chapter is a "lesson". Each chapter ends with exercises. Do (some of) the exercises. K&R is very readable. It's concise, but very clear.
2) Math and logic will prove helpful.

Another thing that I find helpful is "role playing". When writing a function, think of yourself as the function, and ask, what am I provided (the function parameters) and what must I do (the functional requirement). A good function does exactly ONE thing, calling other functions as necessary to do that thing. Many functions do nothing other than call other functions (are "implemented in terms of" other functions) in some order.

Functions can be broadly divided into three types: those that transform their argument(s) into some other thing (the result), those that have side effects (chnage something external to the function), and those that provide a single "facade'" that calls other functions in some order (do this, then do that, then do something else).

Finally, avoid like the plague any book by Herb Schildt.
posted by orthogonality at 11:13 PM on May 21, 2008 [1 favorite]


I used K&R in my Intro to Programming class in my first year class (2003), it seemed pretty clear.

Also, no offence to your friend, but is he really going to be a good teacher if he's learning the language as you both go along?
posted by jacalata at 11:45 PM on May 21, 2008


Have you considered learning C++ ? I really enjoyed "Thinking in C++" by Bruce Eckel. I've used it to teach C++ classes as well, and the students loved it. It's also very well written, and chapter 3 ("The C in C++") brings you up to speed on the bulk of C programming.

If you're going to do programming on the Windows OS, I'd suggest getting the free Turbo C++ 2006 compiler from Borland, which also is a RAD tool so you can easily make Windows programs and try out the stuff you've learned. At any rate, you can create simple console mode programs with a main() function, like you will see in exercises from any C/C++ tutorial or book. Just a suggestion!

Good luck,


Hens Zimmerman
posted by hz37 at 12:03 AM on May 22, 2008


If K&R is the King James, H&S is the Good News.

Contrary to many, I think C is an excellent pick for a first computer language, for those who have the patience to take a systematic approach to self-education. It's close enough to the machine to give you a solid grounding in how computers actually work, but high-level enough that you can write readable, maintainable and even re-usable code in it. Also, much of what has come since is in direct response to fixing assorted shortcomings of C. Until you've banged your head against those for a while, you won't really be well placed to appreciate the fixes.

For Kernighan's sake don't go near C++ until you understand C.
posted by flabdablet at 12:58 AM on May 22, 2008 [1 favorite]


If you've never programmed before, I'd suggest the lower-learning-curve Deitel and Deitel C How to Program.
posted by alasdair at 1:02 AM on May 22, 2008


When I was taking my first CS classes in college, Eric Roberts' books The Art and Science of C and Programming Abstractions in C were the standard coursebooks for Stanford's two-quarter introductory series that served as both an introduction to C as well as an introduction to programming.

They aren't books you'll reference much later on in your programming career, but they do quite a good job at using C to teach the more general programming concepts that you'll need regardless of what language you're using.

As with most college textbooks, the new book prices are insane. Buy used.
posted by strangecargo at 1:07 AM on May 22, 2008 [1 favorite]


K&R is very well written and very concise.
If you want to learn C++, start with an early slim edition of Stroustrup's instead of the current verbose edition.
posted by flif at 5:04 AM on May 22, 2008


Harbison and Steele's "C: A Reference Manual" is the best reference there is. It is not a tutorial, but when you have a question about some facet, this is The Book to pick up.
posted by cmiller at 6:07 AM on May 22, 2008 [1 favorite]


I'm with the crowd on recommending Harbison & Steele over K&R.
posted by pharm at 6:25 AM on May 22, 2008


I keep K&R as a reference, but C Primer Plus is what I started with.
posted by kableh at 7:29 AM on May 22, 2008


C is not a good language to learn unless you are going to be using it every week. Assess why you want to learn, and pick a suitable language.

To find books that match your learning style, go and browse in a real bricks-and-mortar book shop with real paper books. If you are doing this seriously you probably need more than one -- an easy introduction and something that takes the ideas further.
posted by Idcoytco at 8:29 AM on May 22, 2008


If I wasn't a programmer, and I started by learning C, I would never be a programmer. I'd go nuts. Learn something object-oriented first.

Clearly that's just my opinion though.
posted by East Manitoba Regional Junior Kabaddi Champion '94 at 8:52 AM on May 22, 2008


"C for dummies" was my textbook for first year university, and so far, I haven't failed to find a single bit of information in the thing. It's got a really great learning curve.
posted by tehloki at 9:04 AM on May 22, 2008


Deitel and Deitel is horrible, terrible and boring. Sorry, I can't really recommend it.

I learned C++ using the Borland Turbo C++ 3.0 manual and found it quite useful, but I suppose that isn't really something one can easily find these days.

See also.

I would recommend Stroustrup's books.
posted by jeffamaphone at 10:14 AM on May 22, 2008


I started with C and with Deitel and Deitel, and I second all the "that'll scare you off the art for life" commentary. If K&R is a better read, go with that.

(I had to get into Python to realize that I'm probably nowhere near as bad of a novice coder as Intro to C at my first university made me think I was. The combination of bad lecturer, bad examples, Deitel and Deitel, an incomprehensible TA, and the language itself just conspired to make me freeze up every time I sat down to code.)
posted by fairytale of los angeles at 10:28 AM on May 22, 2008


I got (and still get) some good mileage out of Introductory C: Pointers, Functions and Files. It doesn't assume the reader has programmed before and starts with basic programming concepts concepts, paired with the C implementations.
posted by speedo at 10:44 AM on May 22, 2008


If you'll be learning C on a Mac, get Dave Mark's "book" (PDF) from Spiderworks. It worked great for me.
posted by neuron at 1:29 PM on May 22, 2008


I really like K&R. It's probably one of the best written programming books I've read. It is terse, but not to the point of being incomprehensible. It's also a nice read. (I like Stoustrup's C++ book, but it is certainly not as well written.)
posted by chunking express at 8:38 AM on May 26, 2008


If K&R is the King James, and H&S is the Good News, then the Lions Book is the Dead Sea Scrolls.

When the Lions Book is no longer perplexing, you've learned C.
posted by flabdablet at 7:05 AM on May 27, 2008


« Older Recording in the bar, stupid or just awesome?   |   Mystery song Newer »
This thread is closed to new comments.