CARVIEW |
C in a Nutshell
- By
- Peter Prinz, Tony Crawford
- Publisher:
- O'Reilly Media
- Released:
- December 2005
- Pages:
- 624
Covering the C programming language and C runtime library, this book is destined to be a constant companion in your work. C in a Nutshell covers virtually everything you need to program in C. Topics include runtime library calls, common compiler options, and questions of C syntax and usage. Not to be missed by C programmers of all levels.
Learning a language--any language--involves a process wherein you learn to rely less and less on instruction and more increasingly on the aspects of the language you've mastered. Whether you're learning French, Java, or C, at some point you'll set aside the tutorial and attempt to converse on your own. It's not necessary to know every subtle facet of French in order to speak it well, especially if there's a good dictionary available. Likewise, C programmers don't need to memorize every detail of C in order to write good programs. What they need instead is a reliable, comprehensive reference that they can keep nearby. C in a Nutshell is that reference.
This long-awaited book is a complete reference to the C programming language and C runtime library. Its purpose is to serve as a convenient, reliable companion in your day-to-day work as a C programmer. C in a Nutshell covers virtually everything you need to program in C, describing all the elements of the language and illustrating their use with numerous examples.
The book is divided into three distinct parts. The first part is a fast-paced description, reminiscent of the classic Kernighan & Ritchie text on which many C programmers cut their teeth. It focuses specifically on the C language and preprocessor directives, including extensions introduced to the ANSI standard in 1999. These topics and others are covered:
- Numeric constants
- Implicit and explicit type conversions
- Expressions and operators
- Functions
- Fixed-length and variable-length arrays
- Pointers
- Dynamic memory management
- Input and output
The second part of the book is a comprehensive reference to the C runtime library; it includes an overview of the contents of the standard headers and a description of each standard library function. Part III provides the necessary knowledge of the C programmer's basic tools: the compiler, the make utility, and the debugger. The tools described here are those in the GNU software collection.
C in a Nutshell is the perfect companion to K&R, and destined to be the most reached-for reference on your desk.
-
Language
-
Chapter 1 Language Basics
- Characteristics of C
- The Structure of C Programs
- Source Files
- Comments
- Character Sets
- Identifiers
- How the C Compiler Works
-
Chapter 2 Types
- Typology
- Integer Types
- Floating-Point Types
- Complex Floating-Point Types (C99)
- Enumerated Types
- The Type void
-
Chapter 3 Literals
- Integer Constants
- Floating-Point Constants
- Character Constants
- String Literals
-
Chapter 4 Type Conversions
- Conversion of Arithmetic Types
- Conversion of Nonarithmetic Types
-
Chapter 5 Expressions and Operators
- How Expressions Are Evaluated
- Operators in Detail
- Constant Expressions
-
Chapter 6 Statements
- Expression Statements
- Block Statements
- Loops
- Selection Statements
- Unconditional Jumps
-
Chapter 7 Functions
- Function Definitions
- Function Declarations
- How Functions Are Executed
- Pointers as Arguments and Return Values
- Inline Functions
- Recursive Functions
- Variable Numbers of Arguments
-
Chapter 8 Arrays
- Defining Arrays
- Accessing Array Elements
- Initializing Arrays
- Strings
- Multidimensional Arrays
- Arrays as Arguments of Functions
-
Chapter 9 Pointers
- Declaring Pointers
- Operations with Pointers
- Pointers and Type Qualifiers
- Pointers to Arrays and Arrays of Pointers
- Pointers to Functions
-
Chapter 10 Structures and Unions and Bit-Fields
- Structures
- Unions
- Bit-Fields
-
Chapter 11 Declarations
- General Syntax
- Type Names
- typedef Declarations
- Linkage of Identifiers
- Storage Duration of Objects
- Initialization
-
Chapter 12 Dynamic Memory Management
- Allocating Memory Dynamically
- Characteristics of Allocated Memory
- Resizing and Releasing Memory
- An All-Purpose Binary Tree
- Characteristics
- Implementation
-
Chapter 13 Input and Output
- Streams
- Files
- Opening and Closing Files
- Reading and Writing
- Random File Access
-
Chapter 14 Preprocessing Directives
- Inserting the Contents of Header Files
- Defining and Using Macros
- Conditional Compiling
- Defining Line Numbers
- Generating Error Messages
- The #pragma Directive
- The _Pragma Operator
- Predefined Macros
-
-
Standard Library
-
Chapter 15 The Standard Headers
- Using the Standard Headers
- Contents of the Standard Headers
-
Chapter 16 Functions at a Glance
- Input and Output
- Mathematical Functions
- Character Classification and Conversion
- String Processing
- Multibyte Characters
- Converting Between Numbers and Strings
- Searching and Sorting
- Memory Block Handling
- Dynamic Memory Management
- Date and Time
- Process Control
- Internationalization
- Nonlocal Jumps
- Debugging
- Error Messages
-
Chapter 17 Standard Library Functions
-
-
Basic Tools
-
Chapter 18 Compiling with GCC
- The GNU Compiler Collection
- Obtaining and Installing GCC
- Compiling C Programs with GCC
- C Dialects
- Compiler Warnings
- Optimization
- Debugging
- Profiling
- Option and Environment Variable Summary
-
Chapter 19 Using make to Build C Programs
- Targets, Prerequisites, and Commands
- The Makefile
- Rules
- Comments
- Variables
- Phony Targets
- Other Target Attributes
- Macros
- Functions
- Directives
- Running make
-
Chapter 20 Debugging C Programs with GDB
- Installing GDB
- A Sample Debugging Session
- Starting GDB
- Using GDB Commands
-
-
Colophon

- Title:
- C in a Nutshell
- By:
- Peter Prinz, Tony Crawford
- Publisher:
- O'Reilly Media
- Formats:
-
- Ebook
- Safari Books Online
- Print Release:
- December 2005
- Ebook Release:
- December 2008
- Pages:
- 624
- Print ISBN:
- 978-0-596-00697-6
- | ISBN 10:
- 0-596-00697-7
- Ebook ISBN:
- 978-0-596-15963-4
- | ISBN 10:
- 0-596-15963-3
-
Peter Prinz
Peter is a seminar leader and key course developer, teaching courses to thousands of software developers for Unix and Windows systems. As the chief developer and cofounder of the IT company Authensis AG in Germany, he has gained extensive experience in software development for computer telephony. Peter is also the author of several other books on software development in C/C++, most of them as co-author with Ulla Kirch-Prinz, including O'Reilly's "C Pocket Reference". -
Tony Crawford
Tony Crawford is a technical-writer and freelance translator with a strong C background based just outside Berlin, Germany. In addition to regular software localization projects, he has translated books on network administration and ATM. A US native, Tony completed undergraduate work at Occidental College, Los Angeles; Universit de Perpignan, France; and Technische Universit t, Berlin. Tony translates from German into English.
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects.
The animal on the cover of C in a Nutshell is a cow, in the broad sense that it is a member of the domesticated species generally known as Western or European cattle (Bos taurus). In cattle terminology, the word "cow" refers to an adult female (or more specifically, a female who has given birth), as opposed to a heifer (young female), steer (castrated male), or bull (intact male).
All domesticated cattle evolved from aurochs, ancient long-horned oxen that stood six feet at the shoulder and had roughly half the mass of a rhinoceros. The head of an aurochs (the term is both singular and plural) is currently featured on the Romanian coat of arms and the Moldovan flag, tracing back to the royal standard adopted in 1359 by Bogdan I, founder of the Romanian principality of Bogdania (later renamed Moldova). Full-body profiles of the animal survive in Paleolithic European cave paintings, and animated renderings can be found in video games; aurochs have been objects of fear and worship in a number of societies through the ages.
Aurochs are believed to have originated in India some two million years ago; over time, they spread to neighboring continents and split into at least three genetically distinct groups, which were domesticated independently. Domestication of aurochs began in the southern Caucasus and northern Mesopotamia 8,000 to 10,000 years ago; European cattle descended from this group. Wild aurochs survived in dwindling numbers in the forests of eastern Europe through the Middle Ages (the last one was killed by a poacher in 1627). Attempts were made in Germany in the early twentieth century to breed aurochs back into existence (guided by a pre-Darwinian concept of atavism), using primitive varieties of cattle such as Highland Cattle; the result is a breed known as Heck Cattle.
European cattle, brought to the Americas by Columbus on his second voyage, now number in the hundreds of breeds. It is a popular misconception that only the males have horns; in fact, both sexes are born with horns (except in a few breeds that are polled, or naturally hornless). Seeing horns other than on isolated bulls is unusual because of the common practice in modern cattle management of debudding calves at or shortly after birth (that is, removing the immature base, or horn bud, before an actual horn develops).
Cow horns, which consist of a bony core sheathed in keratinous material, figure in the history of book manufacturing and the promulgation of the alphabet. In sixteenth- to eighteenth-century Europe and in colonial America, a common type of primer was composed of the alphabet (plus other text that varied) printed or written on one side of a piece of paper or parchment, which was then attached to a wooden board and covered with a thin, transparent sheet culled from the outer layer of a cow horn. The board was shaped like a small paddle (with a hole in the handle for attachment to a girdle) to make it easy to transport and share among students. The protective layer of horn extended the life of the paper (a scarce and expensive resource) and inspired the name for the device: a hornbook.
Abby Fox was the production editor for C in a Nutshell. Nancy Kotary was the copyeditor, and Nancy Reinhardt proofread the book. Jamie Peppard and Claire Cloutier provided quality control. Ellen Troutman Zaig wrote the index. Karen Montgomery designed the cover of this book, based on a series design by Edie Freedman. The cover image is an original illustration created by Susan Hart. Karen Montgomery produced the cover layout with Adobe InDesign CS using Adobe's ITC Garamond font.
David Futato designed the interior layout. This book was converted by Keith Fahlgren from Microsoft Word to Adobe FrameMaker 5.5.6 using Open Source XML technologies. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSans Mono Condensed. The illustrations that appear in the book were produced by Robert Romano, Jessamyn Read, and Lesley Borash using Macromedia FreeHand MX and Adobe Photoshop CS. The tip and warning icons were drawn by Christopher Bing. This colophon was written by Abby Fox.
![]() ©2010, O'Reilly Media, Inc. (707) 827-7000 / (800) 998-9938 All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. |
About O'Reilly
Academic Solutions Authors Contacts Customer Service Jobs Newsletters O'Reilly Labs Press Room Privacy Policy RSS Feeds Terms of Service User Groups Writing for O'Reilly |
Content Archive Business Technology Computer Technology Microsoft Mobile Network Operating System Digital Photography Programming Software Web Web Design |
More O'Reilly Sites
O'Reilly Radar Ignite Tools of Change for Publishing Digital Media Inside iPhone makezine.com craftzine.com hackszine.com perl.com xml.com Partner Sites InsideRIA java.net O'Reilly Insights on Forbes.com |