Book on C, A: Programming in C

Al Kelley / Ira Pohl  
Total pages
December 1997
Related Titles

Product detail

Product Price CHF Available  
Book on C, A: Programming in C
88.10 approx. 7-9 days


Written by best-selling authors Al Kelley and Ira Pohl, A Book on C, Fourth Edition is a comprehensive tutorial and reference to C based on the ANSI C standard. The C language is demonstrated with numerous examples and extensive exercises that guide readers through each concept. Step-by-step "dissections" of program code reveal the underlying logic of the programs and include in-depth implementation details. New features in this edition include: a chapter on moving from C to Java; more programming examples; new and improved dissections; more thorough coverage of multifile programming, pointers, and recursion; and new and updated exercises; and an expanded appendix of standard library functions. In addition, there is more emphasis on Abstract Data Types, which provides the reader with a foundation for working with objects and facilitates programming in the problem domain.

Table of Contents

(Each chapter concludes with a Summary and Exercises.)


Starting from Zero.

Why C?

ANSI C Standard.

From C to C++.

From C and C++ to Java.

1. An Overview of C.

Programming and Preparation.

Program Output.

Variables, Expressions, and Assignment.

The Use of #define and #include.

The Use of printf() and scanf().

Flow of Control.



Arrays, Strings, and Pointers.





Operating System Considerations.

Writing and Running a C Program.

Interrupting a Program.

Typing an End-of-file Signal.

Redirection of the Input and the Output.

2. Lexical Elements, Operators, and the C System.

Characters and Lexical Elements.

Syntax Rules.





String Constants.

Operators and Punctuators.

Precedence and Associativity of Operators.

Increment and Decrement Operators.

Assignment Operators.

An Example: Computing Powers of 2.

The C System.

The Preprocessor.

The Standard Library.

3. The Fundamental Data Types.

Declarations, Expressions, and Assignment.

The Fundamental Data Types.

Characters and the Data Type char.

The Data Type int.

The Integral Types short, long, and unsigned.

The Floating Types.

The Use of typedef.

The sizeof Operator.

The Use of getchar() and putchar().

Mathematical Functions.

The Use of abs() and fabs().

UNIX and the Mathematics Library.

Conversions and Casts.

The Integral Promotions.

The Usual Arithmetic Conversions.


Hexadecimal and Octal Constants.

4. Flow of Control.

Relational, Equality, and Logical Operators.

Relational Operators and Expressions.

Equality Operators and Expressions.

Logical Operators and Expressions.

Short-circuit Evaluation.

The Compound Statement.

The Expression and Empty Statement.

The if and the if-else Statements.

The while Statement.

The for Statement.

An Example: Boolean Variables.

The Comma Operator.

The do Statement.

An Example: Fibonacci Numbers.

The goto Statement.

The break and continue Statements.

The switch Statement.

The Conditional Operator.

5. Functions.

Function Definition.

The return Statement.

Function Prototypes.

Function Prototypes in C++.

An Example: Creating a Table of Powers.

Function Declarations from the Compiler's Viewpoint.


An Alternate Style for Function Definition Order.

Function Invocation and Call-by-Value.

Developing a Large Program.

What Constitutes a Large Program?

Using Assertions.

Scope Rules.

Parallel and Nested Blocks.

Using a Block for Debugging.

Storage Classes.

The Storage Class auto.

The Storage Class extern.

The Storage Class register.

The Storage Class static.

Static External Variables.

Default Initialization.


Efficiency Considerations.

An Example: The Towers of Hanoi.

6. Arrays, Pointers, and Strings.

One-dimensional Arrays.





The Relationship Between Arrays and Pointers.

Pointer Arithmetic and Element Size.

Arrays as Function Arguments.

An Example: Bubble Sort.

Dynamic Memory Allocation With calloc() and malloc().

Offsetting the Pointer.

An Example: Merge and Merge Sort.


String-Handling Functions in the Standard Library.

Multidimensional Arrays.

Two-dimensional Arrays.

The Storage Mapping Function.

Formal Parameter Declarations.

Three-dimensional Arrays.


The Use of typedef.

Arrays of Pointers.

Arguments to main().

Ragged Arrays.

Functions as Arguments.

Functions as Formal Parameters in Function Prototypes.

An Example: Using Bisection to Find the Root of a Function.

The Kepler Equation.

Arrays of Pointers to Function.

The Type Qualifiers const and volatile.

7. Bitwise Operators and Enumeration Types.

Bitwise Operators and Expressions.

Bitwise Complement.

Two's Complement.

Bitwise Binary Logical Operators.

Left and Right Shift Operators.


Software Tools: Printing an int Bitwise.

Packing and Unpacking.

Multibyte Character Constants.

Enumeration Types.

An Example: The Game of Paper, Rock, Scissors.

8. The Preprocessor.

The Use of #include.

The Use of #define.

Syntactic Sugar.

Macros with Arguments.

The Type Definitions and Macros in stddef.h.

An Example: Sorting with qsort().

An Example: Macros with Arguments.

The Macros in stdio.h and ctype.h.

Conditional Compilation.

The Predefined Macros.

The Operators # and ##.

The assert() Macro.

The Use of #error and #pragma.

Line Numbers.

Corresponding Functions.

An Example: Quicksort.

9. Structures and Unions.


Accessing Members of a Structure.

Operator Precedence and Associativity: A Final Look.

Using Structures with Functions.

Initialization of Structures.

An Example: Playing Poker.


Bit Fields.

An Example: Accessing Bits and Bytes.

The ADT Stack.

10. Structures and List Processing.

Self-referential Structures.

Linear Linked Lists.

Storage Allocation.

List Operations.

Some List Processing Functions.




An Example: Polish Notation and Stack Evaluation.


Binary Trees.

Binary Tree Traversal.

Creating Trees.

General Linked Lists.


The Use of calloc() and Building Trees.

11. Input/Output and the Operating System.

The Output Function printf().

The Input Function scanf().

The Functions fprintf(), fscanf(), sprintf(), and sscanf().

The Functions fopen() and fclose().

An Example: Double Spacing a File.

Using Temporary Files and Graceful Functions.

Accessing a File Randomly.

File Descriptor Input/Output.

File Access Permissions.

Executing Commands from Within a C Program.

Using Pipes from Within a C Program.

Environment Variables.

The C Compiler.

Using the Profiler.


How to Time C Code.

The Use of make.

The Use of touch.

Other Useful Tools.

12. Advanced Applications.

Creating a Concurrent Process with fork().

Overlaying a Process: the exec...() Family.

Using the spawn...() Family.

Interprocess Communication Using pipe().


An Example: The Dining Philosophers.

Dynamic Allocation of Matrices.

Why Arrays of Arrays Are Inadequate.

Building Matrices with Arrays of Pointers.

Adjusting the Subscript Range.

Allocating All the Memory at Once.

Returning the Status.

13. Moving from C to C++.




Classes and Abstract Data Types.


Constructors and Destructors.

Object-oriented Programming and Inheritance.



C++ Exceptions.

Benefits of Object-oriented Programming.

14. Moving from C to Java.


Variables and Types.

Classes and Abstract Data Types.


Construction and Destruction of Class Types.

Object-oriented Programming and Inheritance.

Polymorphism and Overriding Methods.


Java Exceptions.

Benefits of Java and OOP.

Appendix A. The Standard Library.


Character Handling.

Testing a Character.

Mapping a Character.


Floating Limits.

Integral Limits.



Nonlocal Jumps.

Signal Handling.

Variable Arguments.

Common Definitions.


Opening, Closing, and Conditioning a File.

Accessing the File Position Indicator.

Error Handling.

Character Input/Output.

Formatted Input/Output.

Direct Input/Output.

Removing or Renaming a File.

A.13 General Utilities.

Dynamic Allocation of Memory.

Searching and Sorting.

Pseudo Random-Number Generator.

Communicating with the Environment.

Integer Arithmetic.

String Conversion.

Multibyte Character Functions.

Multibyte String Functions.

Leaving the Program.

Memory and String Handling.

Memory-Handling Functions.

String-Handling Functions.

Date and Time.

Accessing the Clock.

Accessing the Time.


File Access.

Using File Descriptors.

Creating a Concurrent Process.

Overlaying a Process.

Interprocess Communication.

Suspending Program Execution.

Appendix B. Language Syntax.


Function Definition.





String Literal.


Appendix C. ANSI C Compared to Traditional C.








Array Pointers.

Structures and Unions.


Header Files.


Appendix D. ASCII Character Codes.

Appendix E Operator Precedence and Associativity.

Index. 0201183994T04062001

Back Cover

Now in its fourth edition, A Book on C retains the features that have made it a proven, best-selling tutorial and reference on the ANSI C programming language. This edition builds on the many existing strengths of the text to improve, update, and extend the coverage of C, and now includes information on transitioning to Java and C++ from C.

Beginners and professional programmers alike will benefit from the numerous examples and extensive exercises developed to guide readers through each concept. Step-by-step dissections of program code illuminate the correct usage and syntax of C language constructs and reveal the underlying logic of their application. The clarity of exposition and format of the book make it an excellent reference on all aspects of C.

Highlights of A Book on C, Fourth Edition :

  • New and updated programming examples and dissections-the authors' trademark technique for illustrating and teaching language concepts.
  • Recursion is emphasized with revised coverage in both the text and exercises.
  • Multifile programming is given greater attention, as are the issues of correctness and type safety. Function prototypes are now used throughout the text.
  • Abstract Data Types, the key concept necessary to understanding objects, are carefully covered.
  • Updated material on transitioning to C++, including coverage of the important concepts of object-oriented programming.
  • New coverage is provided on transitioning from C to Java.
  • References to key programming functions and C features are provided in convenient tables.

  • Author

    Ira Pohl is a Professor of Computer Science at the University of California, Santa Cruz and holds a Ph.D. in Computer Science from Stanford University. His research interests include artificial intelligence, the C and C++ programming languages, practical complexity problems, heuristic search methods, deductive algorithms, and educational and social issues. He originated error analysis in heuristic search methods and deductive algorithms.

    Professor Pohl was formerly a Mackay professor at University of California- Berkeley and a ZWO fellow in the Netherlands. He is the author or co-author of Object-Oriented Programming Using C++, C++ Distilled: A Concise Ansi/Iso Reference and Style Guide, C by Dissection: The Essentials of C Programming, A Book on C: Programming in C, C++ for C Programmers, C++ for Fortran Programmers, C++ for Pascal Programmers, and Turbo C: The Essentials of C Programming, all published by Addison-Wesley.