Jump to ratings and reviews
Rate this book

The C Programming Language

Rate this book
This book is meant to help the reader learn how to program in C. It is the definitive reference guide, now in a second edition. Although the first edition was written in 1978, it continues to be a worldwide best-seller. This second edition brings the classic original up to date to include the ANSI standard.

From the Preface:
We have tried to retain the brevity of the first edition. C is not a big language, and it is not well served by a big book. We have improved the exposition of critical features, such as pointers, that are central to C programming. We have refined the original examples, and have added new examples in several chapters. For instance, the treatment of complicated declarations is augmented by programs that convert declarations into words and vice versa. As before, all examples have been tested directly from the text, which is in machine-readable form.

As we said in the first preface to the first edition, C "wears well as one's experience with it grows." With a decade more experience, we still feel that way. We hope that this book will help you to learn C and use it well.

272 pages, Paperback

First published January 1, 1978

Loading interface...
Loading interface...

About the author

Brian W. Kernighan

38 books261 followers
Brian Wilson Kernighan is a computer scientist who worked at Bell Labs alongside Unix creators Ken Thompson and Dennis Ritchie and contributed greatly to Unix and its school of thought.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
6,214 (59%)
4 stars
2,892 (27%)
3 stars
1,037 (9%)
2 stars
205 (1%)
1 star
88 (<1%)
Displaying 1 - 30 of 496 reviews
Profile Image for Nick Black.
Author 1 book711 followers
September 4, 2021
Found myself rereading this the other day, after recommending Chapter 8 to a young engineer seeking the Truth behind malloc(3)...still as fresh as the day it was printed, although I do note minor failings now (ubiquitous definitions of MAXLINE to 1000 rather than idiomatic use of ANSI/ISO's BUFSIZ, rather more use of register than I care to see in peacetime, etc). Also, when are we getting an update for C99? I'd like to see more people making proper use of stdint.h than is today typical.

Say what you will about C. I thought it close to perfect upon first grokkage back in that beatific summer of 1995. A year's eager detour into Prolog advocacy made absolutely clear the walls of the logical paradigm. Alexandrescu's marvelous work in metaprogramming was by that time mainstream, or as mainstream as it will ever be or need to be; for two years I became an effete C++ snob, until I realized just how poisonous it is when inflicted upon actual teams. The time was right to worship at Hindley and Milner's altars, and much joy was had hacking away in SML and OCamL—still wonderful languages, to which I return when my code needn't, say, read or write data. But while my heart might pump pure computation, my ass rests firmly before the loom of systems programming; short-lived, sweaty, heavy-breathed infatuations with Haskell, Erlang, and most recently Scala have left indelible imprints, but only on a mind aimed like a missile at hacking UNIX applications on supercomputers—or whatever's bigger.

(I've recently developed a curmudgeonly fondness regarding FORTRAN, largely due to an absence of pointer-aliasing issues (and thus massively simplified construction of optimizing compilers). This is more due to C99's baroque restrict system than anything else, and of course an unsatisfiable impulse towards contrarianism.)

And so I return always to C, not my first but certainly my most torrid and long-affected love. It's likely the only usable language I'll ever have truly memorized in all its detail. I've dreamed in C too many nights to count—not about discussing C, or debugging C, or writing C, but being C code and interacting with other entities as God meant us to: call-by-value reduction strategy. It is an imperfect language. Truth be told, it's in ways not even an acceptable language.

But I too am an imperfect vessel, and I've erected yet great castles in the air, from air, creating—by exertion of the imagination—real tools and potent effects. The greatest of these have shared one feature all: they were set down in the language of Kernighan and Ritchie, the syntactic heritage of systems programmers since the minicomputer era. Each year a few new hackers come under my wing, and more often than not it is my privilege to guide them through C's finer points. Frustration and puzzlement give way to understanding of, say, array-pointer equivalence or userspace threading via sigaltstack(2) trampolines, and in their delighted faces I see a bit of my youth...how many years spent in a phosphoric VGA glow, gnashing teeth, finally greeting sunrise with the wild-eyed exhilaration of Victory, screwing a Lucky Strike between my lips and knowing the problem has been solved? Millions of programmers around the world, thousands of epiphanies a second, synapses firing and recoiling by the trillion, transistors uncountable switching through forbidden zones from 0 to 1, all of them ordered by the principles set out in 189 pages plus appendices.

Well-played, sirs.


update: Dennis M. Ritchie exited with status code 0, EXIT_SUCCESS, 2011-10-13. He will be missed.


update 2, 2020-10-12: i have finally found a language better for most tasks than C: rust. still, fifty-odd years of dominance are nothing to sneeze at.
Profile Image for Manny.
Author 29 books13.6k followers
February 13, 2009
If you're a geek, you have to prostrate yourself in the direction of Bell Labs whenever this book is mentioned. I'm not really a geek, so it's optional.

Well, perhaps I'd better do it anyway. Just in case.

Profile Image for Michael Finocchiaro.
Author 3 books5,533 followers
November 22, 2016
For evolution of the planet earth and our modern understanding of biology, there was Darwin's Origin of the Species. For mathematics, there was Newton's Philosophiæ Naturalis Principia Mathematica. Well, for the internet, for Facebook, for LinkedIn, Twitter, Instgram, Snapchat, WhatsApp, Pornhub amd even the odious website for Justin Bieber would never have existed without Kernigan and Ritchie (more affectionately known as K&R)'s classic, The C Programming Language. What language was TCP/IP written in? C. What language inspired both C++ and Java (and the abominable C#)? C. What language are most libraries on most operating systems written in if not assembler? C. The book is the raging hardon that spawned the last 40 some-odd years of quantum leaps in computer science and changed humanity forever? Am I exaggerating? Hardly. This book is highly readable (ok a bit dry but did you try reading Darwin or Newton? They are longer and dryer believe you me!). If you want to geek out on just one book then this is the one. RIP Ritchie and long live Kernigan!
Profile Image for Aleksandra.
115 reviews34 followers
March 23, 2021
I‘m in my second semester and we are being taught (beside algorithms) the C programming language. In the first semester we were introduced to this (for me) completely new world - world of programming - through Python.

As someone that had no prior experience with programming, this book had definitely helped and explained A LOT - it definitely (I‘d say) covers pretty much everything!

Even though I am still making some syntax errors (thanks Python😭), I‘m making some progress, which definitely keeps me motivated to continue with my practice in hope that I'll successfully learn it one day! 😅
Profile Image for P Doerr lulz.
1 review
March 25, 2008
Excellent A+++++++ Would read again!
The C Programming Language is THE VERY BEST way to learn the C programming language. Starting with the basic "Hello World" program, this book covers everything (of course, as the official guide to the language this is expected). As any programmer worth his salt will tell you, C is one of the most useful languages, and at least basic knowledge is mandatory.
3 reviews
April 16, 2009
Regardless of the fact that the architect of the language is a co-author, this book is simply not a good book on discussing the intricacies of C, a language replete with low-level details defining its behavior.

Everything, including a discussion on sequence points and side effects, among other topics, is included in Peter Prinz's and Tony Crawford's C in a Nutshell, which is masterful in its coverage of the language. Combine C in a Nutshell with Summit's C Programming FAQs and you have the entire language at your disposal.
Profile Image for Jim.
Author 7 books2,027 followers
December 17, 2012
I read this years ago when I was first taking C. I don't have this edition, but an earlier one. After wading through several other books, I kept coming back to this one as a reference while programming. It is deceptively short & sweet. Re-reads constantly found me more avenues to explore using their basics.

I gave a copy to my son & he came to the same conclusion. While other, larger, & more specific books come & go as C evolves, this basic work is a must for any serious programmer.
Profile Image for Jeffrey Rubard.
35 reviews3 followers
August 13, 2018
You Say You Want to Learn to Program, Well, You've Got to Read This Book...

The C Programming Language (1978, rev. 1988) is rather totally the most important book ever written about computer science. As the language's name "C" indicates it was not the first language to include block form (that was Algol, a "committee" prototype language never used extensively in industry) and modern control structures, but its centrality and ubiquity in programming projects up to the present day has meant that one has to search far and wide to find a newer computer language that does not importantly incorporate elements from it. One of C's inventors, Dennis Ritchie, paired with Brian Kernighan to produce a slim introduction to programming in it (and, by extension, programming in general); the book has never been out of print since, and in fact has not been revised since the 2nd edition covering the ANSI standard for C in the late '80s.

That being said, someone with dreams of "coding" circa 2018 absolutely cannot pass up the minimal effort necessary to study and comprehend this book; one will be able to "parse" seemingly-terse C programs after reading it, and one additionally gets a postage-stamp introduction to the Unix operating system (the ancestor of Linux and macOS whose principles power the Internet). In reading it you not only learn the basics of C programming, but "absorb" an introduction to the style of thinking once known as "MIS", the practical business of Informatik more concerned with quantifiable success than the big dreams we read about today. Although there has been "price creep" for a basic trade paperback in recent years, it is still worth the price if you want to be a computer professional.
Profile Image for Darshana Unnikrishnan.
79 reviews133 followers
December 6, 2017
The book is missing many important parts of the subject. Also the explanations are not so good. Not suitable for someone who wants to learn the subject from scratch. May be an experienced professional might be able to benefit from the book better.

As for me I was just trying brush up the knowledge I had about this subject but didn't find the book that useful.
Profile Image for Christopher.
50 reviews14 followers
June 15, 2008
Ok dudes, this is THE book. If you want to know how to program in C, the once and future language of all computing, you must buy this book.

EFF this C#, CLI, J#, VB, and all those other abominational languages that are trying to kill good programming skills. If you want to learn how to really program you need to DO this book.

You don't read this book, you DO it! Thought I made a typo, huh? As a general rule, shorter books are better than those SAMS-type 1000 page tomes, teach you more, and are harder to write. When looking for a good technical book on any subject, make sure you try to find the small ones!
Profile Image for Xinyu.
146 reviews29 followers
September 1, 2020
So lucky I did read this book during the summer and started to audit classes using more serious language last winter... Otherwise, this first project of the semester would be even more of a struggle.
Profile Image for AmirMohammad Taati.
4 reviews1 follower
August 4, 2022
Skimming through this book was really enjoyable and fun. This book is not just about C programming language, but also about how to write good code in general. Reading this book is definitely recommended.
Profile Image for Barry.
19 reviews7 followers
August 12, 2008
I can't say I learned how to program C using this book -- that distinction goes to the long-forgotten Microsoft Quick C for Windows manuals and a reference manual put out by the Waite Group. I can't even say that I need to consult this very often anymore, although it will quickly clear up any questions you might have about arrays of pointers to unions of structs.

This book is the ideal presentation of a language. (When was the last time you saw both the grammar and standard library of a language tucked into a couple of appendixes?) Don't read this book to learn C -- that a skill fewer and fewer people need to master. Read this book to learn how documentation ought to be written.

Profile Image for Jacob Williams.
444 reviews7 followers
January 15, 2021
A great example of how to write a solid programming language tutorial: not too shallow, numerous complete programs, lots of good exercises. It's also a neat window into an earlier, very different time in the programming world.

This sometimes still makes lists of "best books for learning C", and I'm giving it a mediocre rating simply to push back against that. This book is older than I am; new versions of the language have been standardized three times since it was published, and the landscape of computing in general has changed drastically too. I was drawn to it out of historical interest, but if you just want to get a practical knowledge of C as efficiently as possible you should be looking for much more recent sources.
Profile Image for Arun.
156 reviews34 followers
August 30, 2019
Used to remember reading this in high school (coming to me only in vague shapes of green with distorted contours of my school lab receding from my minds grasp)...

A masterpiece of pure technical brilliance. You gotta C and read() for yourself.
October 15, 2022
The bible of C programming. A little out of date with occasional contradictions to the modern C standard, but essential for any C enthusiast.
Profile Image for Ajam.
161 reviews12 followers
Shelved as 'dnf'
November 27, 2021
For those uninterested in the historical context or don't want to know why this book is was considered the de-facto book to teach oneself C (just knowing that it was, is enough trivia for the avg Programmer) before slightly better and updated alternatives like C Programming: A Modern Approach came along, just SKIP.
It's 2021 and there exist way better and updated resources and for free.
Profile Image for Ettore Pasquini.
135 reviews111 followers
October 19, 2010
Any software (hell, even hardware) engineer has hopefully heard about this book. If you don't own it, buy it right now! You won't find a single engineer on Earth telling you this is something less that awesome. This book achieves the perfect balance between terseness and exhaustiveness.

Computer Science book writers and publishers: can we go back to a writing style where computer books are in the 150 - 200 pages range, instead of the regular 600 - 900? Come on.
Profile Image for Kenghis Khan.
135 reviews21 followers
July 26, 2007
I simply do not understand why this book is so popular. I find it utterly unreadable and a pain in the butt to use. There are much better books introducing you to C, that serve as a reference to C, etc... Use if you want to impress your friends; otherwise, there are other places to look.
Profile Image for Kyusik Chung.
6 reviews110 followers
March 17, 2011
Truly the C Bible

If only all programming books were this succinct and to the point...
Profile Image for Wouter.
Author 2 books24 followers
July 13, 2018
Oldschool but still relevant, just as the language. It's not a thick book, compared to the four times heavier C++ Primer and that's exactly how I feel about both languages. The C Prog. lang. does a fine job at explaining the key components of the C language using rudimentary code - and I like that, because that's what you'll encounter in the C world. The quicksort implementation using pointers for example. There's not much to say: it's a great introduction and reference, although learning C can easily be done on the internet. Pitfalls and strange usages of preprocessor flags are also covered.
February 24, 2023
This is THE book for learning ANSI C. Kernighan's book does an excellent job holding your hand through the process of learning the basics of memory allocation and low level programming. Definitely an essential read for the entry level developer.
Also, understanding the contents of this book is more than enough information to pass cppinstitute's CLA certification exam.

4 stars because the book is slightly outdated as far as legal and best practices.
Profile Image for Joe Cole.
169 reviews345 followers
January 25, 2017
Yet despite this, I believe there are alternative books which would have made the learning experience at first much easier.

If you have zero experience with programming or C in general, C Programming Absolute Beginner's Guide by Greg Perry and Dean Miller would be the best place to start. It does not get any simpler than this and the book is written with this in mind.
Profile Image for Hots Hartley.
183 reviews8 followers
August 1, 2021
Dry. Boring. Outdated. Lack of imagery. Too much focus on memory management, not enough on UI or usability.

The lessons contained are sound, with examples. But it seems geared to weird, quirky problem-solving programming, like sorting and subclassing, rather than building or architecting of real-life applications. It would benefit from discussion of design patterns (MVC, singleton, etc) and usage in UI, to provide context to motivate the lessons.
Profile Image for Juxhin Deliu.
194 reviews16 followers
February 16, 2019
Utile per chi vuole immergersi nel linguaggio di programmazione più comune, pur richiedendo delle basi di informatica non indifferenti. Dal mio canto, è stato utile come ripasso per l'essenziale del C.
Profile Image for Elijah Oyekunle.
183 reviews27 followers
August 21, 2020
While I've written some C in the past, I needed a brush-up for my Graduate Operating Systems course this fall.

Book is a classic! I'll definitely be revisiting soon.
Displaying 1 - 30 of 496 reviews

Join the discussion

Can't find what you're looking for?

Get help and learn more about the design.