Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
About This eBook
Title Page
Copyright Page
Dedication
Contents
Preface
Acknowledgments
Introduction
The $20 Million Bug
Convention
Some Light Relief—Tuning File Systems
1. C Through the Mists of Time
The Prehistory of C
Early Experiences with C
The Standard I/O Library and C Preprocessor
K&R C
The Present Day: ANSI C
It’s Nice, but Is It Standard?
Translation Limits
The Structure of the ANSI C Standard
Reading the ANSI C Standard for Fun, Pleasure, and Profit
How Quiet is a “Quiet Change”?
Some Light Relief—The Implementation-Defined Effects of Pragmas . . .
2. It’s Not a Bug, It’s a Language Feature
Why Language Features Matter—The Way the Fortran Bug Really Happened!
Sins of Commission
Sins of Mission
Sins of Omission
Some Light Relief—Some Features Really Are Bugs!
3. Unscrambling Declarations in C
Syntax Only a Compiler Could Love
How a Declaration Is Formed
The Precedence Rule
Unscrambling C Declarations by Diagram
typedef Can Be Your Friend
Difference Between typedef int x[10] and #define x int[10]
What typedef struct foo { ... foo; } foo; Means
The Piece of Code that Understandeth All Parsing
Some Light Relief—Software to Bite the Wax Tadpole...
4. The Shocking Truth: C Arrays and Pointers Are NOT the Same!
Arrays Are NOT Pointers!
Why Doesn’t My Code Work?
What’s a Declaration? What’s a Definition?
How Arrays and Pointers Are Accessed
Diagram A A Subscripted Array Reference
Diagram B A Pointer Reference
Diagram C A Subscripted Pointer Reference
Match Your Declarations to the Definition
Other Differences Between Arrays and Pointers
Some Light Relief—Fun with Palindromes!
5. Thinking of Linking
Libraries, Linking, and Loading
The Benefits of Dynamic Linking
Five Special Secrets of Linking with Libraries
Watch Out for Interpositioning
Generating Linker Report Files
Some Light Relief—Look Who’s Talking: Challenging the Turing Test
6. Poetry in Motion: Runtime Data Structures
a.out and a.out Folklore
Segments
What the OS Does with Your a.out
What the C Runtime Does with Your a.out
What Happens When a Function Gets Called: The Procedure Activation Record
The auto and static keywords
Threads of Control
setjmp and longjmp
The Stack Segment Under UNIX
The Stack Segment Under MS-DOS
Helpful C Tools
Some Light Relief—Programming Puzzles at CMU
For Advanced Students Only
7. Thanks for the Memory
The Intel 80x86 Family
The Intel 80x86 Memory Model and How It Got That Way
Virtual Memory
Cache Memory
The Data Segment and Heap
Memory Leaks
Bus Error, Take the Train
Some Light Relief—The Thing King and the Paging Game
8. Why Programmers Can’t Tell Halloween from Christmas Day
The Potrzebie System of Weights and Measures
Making a Glyph from Bit Patterns
Types Changed While You Wait
Prototype Painfulness
Getting a Char Without a Carriage Return
Implementing a Finite State Machine in C
Software Is Harder than Hardware!
How and Why to Cast
Some Light Relief—The International Obfuscated C Code Competition
9. More about Arrays
When an Array Is a Pointer
Why the Confusion?
Why C Treats Array Parameters as Pointers
Indexing a Slice
Arrays and Pointers Interchangeability Summary
C Has Multidimensional Arrays...
...But Every Other Language Calls Them “Arrays of Arrays”
How Multidimensional Arrays Break into Components
How Arrays Are Laid Out in Memory
How to Initialize Arrays
Some Light Relief—Hardware/Software Trade-Offs
10. More About Pointers
The Layout of Multidimensional Arrays
An Array of Pointers Is an “Iliffe Vector”
Using Pointers for Ragged Arrays
Passing a One-Dimensional Array to a Function
Using Pointers to Pass a Multidimensional Array to a Function
Using Pointers to Return an Array from a Function
Using Pointers to Create and Use Dynamic Arrays
Some Light Relief—The Limitations of Program Proofs
11. You Know C, So C++ is Easy!
Allez-OOP!
Abstraction—Extracting Out the Essential Characteristics of a Thing
Encapsulation—Grouping Together Related Types, Data, and Functions
Showing Some Class—Giving User-Defined Types the Same Privileges as Predefined Types
Availability
Declarations
How to Call a Method
Inheritance—Reusing Operations that Are Already Defined
Multiple Inheritance—Deriving from Two or More Base Classes
Overloading—Having One Name for the Same Action on Different Types
How C++ Does Operator Overloading
Input/Output in C++
Polymorphism—Runtime Binding
Explanation
How C++ Does Polymorphism
Fancy Pants Polymorphism
Other Corners of C++
If I Was Going There, I Wouldn’t Start from Here
It May Be Crufty, but It’s the Only Game in Town
Some Light Relief—The Dead Computers Society
Some Final Light Relief—Your Certificate of Merit!
Further Reading
Appendix: Secrets of Programmer Job Interviews
Silicon Valley Programmer Interviews
How Can You Detect a Cycle in a Linked List?
What Are the Different C Increment Statements For?
How Is a Library Call Different from a System Call?
How Is a File Descriptor Different from a File Pointer?
Write Some Code to Determine if a Variable Is Signed or Not
What Is the Time Complexity of Printing the Values in a Binary Tree?
Give Me a String at Random from This File
Some Light Relief—How to Measure a Building with a Barometer
Further Reading
Index
← Prev
Back
Next →
← Prev
Back
Next →