Introduction 1
Chapter 1.A Tutorial Introduction 5
1.1 Getting Started 5
1.2 Variables and Arithmetic Expressions 8
1.3 The For Statement 13
1.4 Symbolic Constants 14
1.5 Character Input and Output 15
1.6 Arrays 22
1.7 Functions 24
1.8 Arguments-Call by Value 27
1.9 Character Arrays 28
1.10 External Variables and Scope 31
Chapter 2.Types,Operators,and Expressions 35
2.1 Variable Names 35
2.2 Data Types and Sizes 36
2.3 Constants 37
2.4 Declarations 40
2.5 Arithmetic Operators 41
2.6 Relational and Logical Operators 41
2.7 Type Conversions 42
2.8 Increment and Decrement Operators 46
2.9 Bitwise Operators 48
2.10 Assignment Operators and Expressions 50
2.11 Conditional Expressions 51
2.12 Precedence and Order of Evaluation 52
Chapter 3.Control Flow 55
3.1 Statements and Blocks 55
3.2 If-Else 55
3.3 Else-If 57
3.4 Switch 58
3.5 Loops-While and For 60
3.6 Loops-Do-while 63
3.7 Break and Continue 64
3.8 Goto and Labels 65
Chapter 4.Functions and Program Structure 67
4.1 Basics of Functions 67
4.2 Functions Returning Non-integers 71
4.3 External Variables 73
4.4 Scope Rules 80
4.5 Header Files 81
4.6 Static Variables 83
4.7 Register Variables 83
4.8 Block Structure 84
4.9 Initialization 85
4.10 Recursion 86
4.11 The C Preprocessor 88
Chapter 5.Pointers and Arrays 93
5.1 Pointers and Addresses 93
5.2 Pointers and Function Arguments 95
5.3 Pointers and Arrays 97
5.4 Address Arithmetic 100
5.5 Character Pointers and Functions 104
5.6 Pointer Arrays; Pointers to Pointers 107
5.7 Multi-dimensional Arrays 110
5.8 Initialization of Pointer Arrays 113
5.9 Pointers vs.Multi-dimensional Arrays 113
5.10 Command-line Arguments 114
5.11 Pointers to Functions 118
5.12 Complicated Declarations 122
Chapter 6.Structures 127
6.1 Basics of Structures 127
6.2 Structures and Functions 129
6.3 Arrays of Structures 132
6.4 Pointers to Structures 136
6.5 Self-referential Structures 139
6.6 Table Lookup 143
6.7 Typedef 146
6.8 Unions 147
6.9 Bit-fields 149
Chapter 7.Input and Output 151
7.1 Standard Input and Output 151
7.2 Formatted Output-Printf 153
7.3 Variable-length Argument Lists 155
7.4 Formatted Input-Scanf 157
7.5 File Access 160
7.6 Error Handling-Stderr and Exit 163
7.7 Line Input and Output 164
7.8 Miscellaneous Functions 166
Chapter 8.The UNIX System Interface 169
8.1 File Descriptors 169
8.2 Low Level I/O-Read and Write 170
8.3 Open,Creat,Close,Unlink 172
8.4 Random Access-Lseek 174
8.5 Example-An Implementation of Fopen and Getc 175
8.6 Example-Listing Directories 179
8.7 Example-A Storage Allocator 185
Appendix A.Reference Manual 191
A1 Introduction 191
A2 Lexical Conventions 191
A3 Syntax Notation 194
A4 Meaning of Identifiers 195
A5 Objects and Lvalues 197
A6 Conversions 197
A7 Expressions 200
A8 Declarations 210
A9 Statements 222
A10 External Declarations 225
A11 Scope and Linkage 227
A12 Preprocessing 228
A13 Grammar 234
Appendix B.Standard Library 241
B1 Input and Output:〈stdio.h〉 241
B2 Character Class Tests:〈ctype.h〉 248
B3 String Functions:〈string.h〉 249
B4 Mathematical Functions:〈 math.h 〉 250
B5 Utility Functions: 〈stdlib.h〉 251
B6 Diagnostics:〈assert.h〉 253
B7 Variable Argument Lists:〈stdarg.h〉 254
B8 Non-local Jumps:〈setjmp.h〉 254
B9 Signals:〈signal.h〉 255
10 Date and Time Functions:〈time.h〉 255
B11 Implementation-defined Limits:〈limits.h〉 and 〈float.h〉 257
Appendix C.Summary of Changes 259
Index 263