C Programming Language,
Second Edition
Brian W. Kernighan and Dennis M. Ritchie

bdbs commerce | beta


Softcover: 272 pages
Publisher: Prentice Hall; Edition 2 (April 1, 1988)
Language: English
ISBN-10: 0131103628
ISBN-13: 978-0131103627
Physical Trim: 9.2 x 6.9 x 0.6 inches

C Programming Language, Second Edition
Brian W. Kernighan and Dennis M. Ritchie

bdbs commerce | beta


'The C Programming Language' (sometimes referred to as 'K&R') is a well-known programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as co-designed the Unix operating system with which development of the language was closely intertwined. The book was central to the development and popularization of the C programming language and is still widely read and used today. Because the book was co-authored by the original language designer, and because the first edition of the book served for many years as the de facto standard for the language, the book is regarded by many to be the authoritative reference on C.


The C Programming Language, Edition 1, 1978

The first edition of the book, published in 1978, was the first widely available book on the C programming language. C was created by Dennis Ritchie. Brian Kernighan wrote the first C tutorial. The authors came together to write the book in conjunction with the language's early development at AT&T Bell Labs. The version of C described in this book is sometimes referred to as 'K&R C' (after the book's authors), often to distinguish this early version from the later version of C standardized as ANSI C.

n 1988 the second edition of the book was published, updated to cover the changes to the C programming language resulting from the new ANSI C standard, particularly with the inclusion of reference material on standard libraries. The second edition (and as of 2012, the most recent edition) of the book has since been translated into over 20 languages.

ANSI C, first standardized in 1988, has since undergone several revisions, the most recent of which is ISO/IEC 9899:2011 (also known as "C11"), adopted as an ANSI standard in October 2011. However, no new edition of The C Programming Language has yet been issued to cover the more recent standards.


'The C Programming Language' has often been cited as a model for technical writing, due to the book's clear presentation and concise treatment. In just 228 pages (272 pages in the second edition), the book covers C comprehensively. Examples generally consist of complete programs of the type one is likely to encounter in daily usage of the language, with an emphasis on system programming. The technical details of C are balanced by the authors' observations on good programming practice, which are immediately illustrated with concrete, realistic examples. As the authors write in the preface to the second edition:

"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."

Perhaps the most famous example program from the book is its "hello world" program, which just prints out the text "hello, world" to the terminal, as an illustration of a minimal working C program. Numerous texts since then have followed that convention for introducing a programming language.

Before the advent of ANSI C, the first edition of the text served as the de facto standard of the language for writers of C compilers. With the standardization of ANSI C, the authors more consciously geared the second edition toward programmers rather than compiler writers; in the authors' own words (again in the preface to the second edition):

"Appendix A, the reference manual, is not the standard, but our attempt to convey the essentials of the standard in a smaller space. It is meant for easy comprehension by programmers, but not as a definition for compiler writers - that role properly belongs to the standard itself. Appendix B is a summary of the facilities of the standard library. It too is meant for reference by programmers, not implementers. Appendix C is a concise summary of the changes from the original version."

The influence of The C Programming Language on programmers, a generation of whom first worked with C in universities and industry, has led many to accept the authors' programming style and conventions as recommended practice, if not normative practice. For example, the coding and formatting style of the programs presented in both editions of the book is often referred to as 'K&R style' or the 'One True Brace Style' and, significantly, became the coding style used by convention in the source code for the Unix and Linux kernels.

About the Authors

Brian W. Kernighan is a Canadian computer scientist who worked at Bell Labs and contributed to the development of Unix. He is also coauthor of the AWK and AMPL programming languages. The 'K' of K&R C and the 'K' in AWK both stand for 'Kernighan'. Brian Kernighan is currently a Professor at the Computer Science Department of Princeton University, where he is also the Undergraduate Department Representative.

Kernighan's name became widely known through co-authorship of the first book on the C programming language with Dennis Ritchie. He authored many Unix programs, including ditroff, and cron for Version 7 Unix.

In collaboration with Shen Lin he devised well-known heuristics for two NP-complete optimization problems: graph partitioning and the travelling salesman problem. (In a display of authorial equity, the former is usually called the Kernighan-Lin algorithm, while the latter is styled Lin-Kernighan.)

Kernighan was the software editor for Prentice Hall International. His "Software Tools" series spread the essence of 'C/Unix thinking' with makeovers for BASIC, FORTRAN, and Pascal - and most notably his 'Ratfor' (rational FORTRAN) was put in the public domain.

Kernighan coined the term Unix in the 1970s. Kernighan is also known as a coiner of the expression "What You See Is All You Get (WYSIAYG)", which is a sarcastic variant of the original "What You See Is What You Get" (WYSIWYG). Kernighan's term is used to indicate that WYSIWYG systems might throw away information in a document that could be useful in other contexts.

Dennis M. Ritchie was the American computer scientist who created the C programming language and, with long-time colleague Ken Thompson, the Unix operating system. Ritchie and Thompson received the Turing Award from the ACM in 1983, the Hamming Medal from the IEEE in 1990 and the National Medal of Technology from President Clinton in 1999.

Ritchie was the head of Lucent Technologies System Software Research Department when he retired in 2007. He was the 'R' in K&R C and commonly known by his username dmr.

Ritchie was born in Bronxville, New York. His father was Alistair E. Ritchie, a longtime Bell Labs scientist and co-author of The Design of Switching Circuits on switching circuit theory. He moved with his family to Summit, New Jersey, as a child, where he graduated from Summit High School. Ritchie graduated from Harvard University with degrees in physics and applied mathematics.

In 1967, he began working at the Bell Labs Computing Sciences Research Center, and in 1968, he received a PhD from Harvard under the supervision of Patrick C. Fischer, his doctoral dissertation being 'Program Structure and Computational Complexity.' Ritchie was best known as the creator of the C programming language, a key developer of the Unix operating system, and co-author, with Kernighan, of 'The C Programming Language,' and was the 'R' in K&R (a common reference to the book's authors Kernighan and Ritchie).

Ritchie worked together with Ken Thompson, the scientist credited with writing the original Unix; one of Ritchie's most important contributions to Unix was its porting to different machines and platforms. The C language is widely used today in application, operating system, and embedded system development, and its influence is seen in most modern programming languages. Unix has also been influential, establishing concepts and principles that are now precepts of computing.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam placerat, velit at volutpat vestibulum, est mauris interdum nisi, ut lobortis mauris nunc vel elit. Praesent vel massa elit. In et dui odio. Aenean pharetra augue eget arcu eleifend laoreet. Nulla vel neque sed arcu rhoncus pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce tortor est, faucibus a suscipit eu, accumsan eget dolor. Aliquam nibh metus, lacinia sit amet feugiat non, gravida nec velit. Quisque accumsan enim eget odio pellentesque tempus. Vestibulum dictum iaculis velit sit amet feugiat.

Phasellus in massa vel ante fermentum venenatis ut nec dui. Proin mollis fermentum blandit. Ut dignissim aliquam neque, eu hendrerit justo bibendum in. Nulla at est vitae quam placerat sagittis et at orci. Aliquam quis urna eget nibh sodales vulputate. Sed hendrerit mattis viverra. Fusce metus est, mattis at mollis nec, mollis vel justo. Nam egestas ultrices tortor, a pellentesque nunc lacinia sit amet. Vestibulum non sapien neque. Nulla blandit felis quis augue viverra faucibus ac non mauris.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sodales leo vitae nibh cursus ullamcorper. Sed gravida mauris ac nisi posuere vel tempus sem mattis. Quisque vitae sem arcu, ac hendrerit lacus. Donec pharetra ipsum ac velit feugiat commodo. Suspendisse condimentum vehicula justo et tincidunt. Praesent iaculis venenatis elit, nec suscipit tortor rutrum in. Curabitur augue neque, elementum eu fermentum et, ullamcorper mollis risus. Ut cursus vestibulum blandit. Donec cursus porta libero, a fringilla turpis egestas ut. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Vivamus orci sapien, pretium ac tincidunt vitae, vestibulum eu enim. Cras congue nisi quis quam consectetur consequat sed ut neque. Mauris id diam lacus, sed gravida quam. Fusce a pretium quam. Duis gravida aliquam cursus. Nam vel elementum metus. Phasellus dapibus, arcu id egestas eleifend, urna ante sagittis leo, ut consectetur nisi justo cursus nibh. Aliquam porttitor, lectus nec placerat sollicitudin, mi magna pellentesque sem, quis porttitor urna risus quis metus. Proin dignissim sollicitudin leo, nec fringilla tellus volutpat. Curabitur velit ante, molestie et facilisis in, tincidunt sit amet sapien. Sed at odio risus, in blandit est. Phasellus tempus, ante sed venenatis suscipit, diam velit vehicula turpis, in placerat lectus tortor non turpis. Fusce a dolor non diam egestas feugiat sed et nisi. Sed ullamcorper elit ac nibh semper vel vestibulum nunc ultrices. Integer varius mi id dolor malesuada vitae ullamcorper libero varius. Duis et orci eros. Maecenas nibh urna, faucibus quis luctus nec, fringilla in nulla. Pellentesque vel massa ligula, sed convallis elit. Proin sapien urna, suscipit ac fringilla hendrerit, vulputate id odio. Phasellus dignissim convallis neque, id lobortis libero vehicula vitae.

Integer urna dolor, semper nec mattis a, suscipit in diam. Nulla tempor enim nisl, ut mollis nisl. Nulla sit amet metus ut enim consequat fermentum. Mauris sed felis urna. Mauris ac nibh lectus, nec lobortis leo. Suspendisse potenti. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent molestie pretium dolor, vel consequat odio varius sit amet. Vestibulum scelerisque feugiat neque, nec sollicitudin turpis faucibus a. Donec eget neque ut purus lobortis congue. Fusce eleifend convallis ipsum, at laoreet dolor dictum ac. Maecenas sed nunc risus. Morbi porta ligula varius leo volutpat sit amet porttitor quam eleifend. Ut iaculis blandit tincidunt. Nullam volutpat, magna at sodales ornare, ligula odio semper neque, adipiscing rhoncus felis leo quis ipsum. Quisque leo orci, ultricies sed lacinia et, volutpat a metus. Aliquam facilisis dapibus lorem, ut scelerisque felis aliquam vitae.

Praesent ligula diam, adipiscing ac congue et, aliquam quis justo. Mauris elementum massa sed libero fermentum vulputate. Ut ligula velit, tincidunt nec scelerisque ac, tincidunt in metus. Vivamus rhoncus nibh ut orci blandit eu varius mi tincidunt. Nulla facilisi. Nunc cursus est in libero rhoncus tincidunt varius enim luctus. Praesent at est mauris. Mauris venenatis dapibus turpis, ut aliquet quam laoreet sit amet. Praesent volutpat, dolor sit amet interdum vulputate, nulla urna pellentesque leo, aliquam accumsan tellus arcu eu leo. Vivamus eget dolor sed sem fringilla rutrum sit amet at augue. Donec hendrerit ipsum vel eros placerat nec dictum ligula dignissim. Vestibulum euismod aliquet tristique. Nam nec mi et elit lobortis interdum. Nulla facilisi. Integer a urna dolor, id suscipit augue. Nullam scelerisque porta lectus, sit amet pellentesque massa tristique et. Donec gravida tincidunt diam vitae tincidunt. Quisque ac turpis sit amet dui consequat ultrices. Maecenas rutrum rutrum magna ut bibendum.

Sed nisl felis, semper eu dapibus non, commodo vitae leo. Nulla at tellus et ligula faucibus adipiscing. Quisque vitae nunc vitae lectus varius porttitor. Duis ut lorem lorem, id mollis sapien. Proin ullamcorper diam id lacus dictum facilisis. Donec porttitor dolor ut mauris viverra rhoncus. Maecenas aliquam magna quis nisl faucibus quis congue nulla molestie. Praesent semper condimentum massa id sollicitudin. Donec mollis rhoncus sapien id molestie. Cras sagittis commodo suscipit. Nullam non nibh in leo aliquam facilisis. Fusce mollis ornare tristique. Donec ultricies condimentum imperdiet. Phasellus tincidunt diam quis elit pharetra laoreet.

Etiam sodales lacus accumsan metus aliquet volutpat ornare enim tempor. Curabitur ac venenatis nulla. Duis condimentum nibh vel sem vestibulum a euismod enim luctus. Duis id leo non dolor lobortis venenatis. Quisque a nulla dolor. Mauris pellentesque dignissim suscipit. Duis dictum tristique pellentesque. Aliquam ornare augue eu nulla rutrum et pretium nibh fermentum. Donec vitae nisi arcu. Proin volutpat urna at enim facilisis nec ornare diam rhoncus.

Integer porttitor, augue non volutpat feugiat, elit ante adipiscing quam, ut scelerisque erat augue quis nisl. In hac habitasse platea dictumst. Etiam sed magna sit amet sem fringilla condimentum. Aliquam in purus sit amet nunc venenatis varius vitae et libero. Fusce ut ornare mi. Quisque lacus mi, egestas eu volutpat ac, vehicula id risus. Mauris venenatis suscipit lacus, et vehicula libero rutrum sit amet. Sed at nibh nisl. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin elit quam, aliquam quis faucibus nec, egestas eget nisl. Vivamus libero arcu, vulputate ut porttitor scelerisque, lacinia auctor turpis. Maecenas id mi et nibh scelerisque molestie. Phasellus ornare, justo eu porta lobortis, sem arcu congue justo, vel pulvinar urna felis ut nisi. Morbi sapien nibh, aliquam a placerat quis, euismod vel risus. Etiam imperdiet varius metus a aliquet. Nullam eget mi vel turpis convallis consequat. Quisque ornare, neque in gravida dignissim, turpis risus dapibus elit, in ultricies ipsum arcu eu nisl. Fusce elementum elit eu lacus euismod eget laoreet metus fermentum. Ut ac felis in urna pellentesque luctus. Nulla odio elit, cursus vitae imperdiet non, pretium vitae felis. Curabitur facilisis, diam sed scelerisque consequat, eros elit faucibus purus, ut vulputate magna ligula vel mi.

Nulla dapibus ornare nisi, et dignissim risus tincidunt nec, etc...