3
4.11.3 Conditional Inclusion..........................................................................................77
Chapter 5 - Pointers and Arrays.............................................................................................78
5.1 Pointers and Addresses................................................................................................78
5.2 Pointers and Function Arguments.................................................................................79
5.3 Pointers and Arrays......................................................................................................81
5.4 Address Arithmetic......................................................................................................84
5.5 Character Pointers and Functions.................................................................................87
5.6 Pointer Arrays; Pointers to Pointers.............................................................................89
5.7 Multi-dimensional Arrays.............................................................................................92
5.8 Initialization of Pointer Arrays.....................................................................................93
5.9 Pointers vs. Multi-dimensional Arrays..........................................................................94
5.10 Command-line Arguments..........................................................................................95
5.11 Pointers to Functions.................................................................................................98
5.12 Complicated Declarations.........................................................................................100
Chapter 6 - Structures..........................................................................................................105
6.1 Basics of Structures...................................................................................................105
6.2 Structures and Functions............................................................................................107
6.3 Arrays of Structures...................................................................................................109
6.4 Pointers to Structures.................................................................................................112
6.5 Self-referential Structures...........................................................................................113
6.6 Table Lookup............................................................................................................117
6.7 Typedef......................................................................................................................119
6.8 Unions.......................................................................................................................120
6.9 Bit-fields....................................................................................................................121
Chapter 7 - Input and Output...............................................................................................124
7.1 Standard Input and Output.........................................................................................124
7.2 Formatted Output - printf...........................................................................................125
7.3 Variable-length Argument Lists..................................................................................127
7.4 Formatted Input - Scanf.............................................................................................128
7.5 File Access.................................................................................................................130
7.6 Error Handling - Stderr and Exit................................................................................132
7.7 Line Input and Output................................................................................................134
7.8 Miscellaneous Functions............................................................................................135
7.8.1 String Operations................................................................................................135
7.8.2 Character Class Testing and Conversion..............................................................135
7.8.3 Ungetc................................................................................................................135
7.8.4 Command Execution...........................................................................................135
7.8.5 Storage Management..........................................................................................136
7.8.6 Mathematical Functions.......................................................................................136
7.8.7 Random Number generation................................................................................136
Chapter 8 - The UNIX System Interface..............................................................................138
8.1 File Descriptors..........................................................................................................138
8.2 Low Level I/O - Read and Write................................................................................139
8.3 Open, Creat, Close, Unlink........................................................................................140
8.4 Random Access - Lseek.............................................................................................142
8.5 Example - An implementation of Fopen and Getc.......................................................142
8.6 Example - Listing Directories.....................................................................................145
8.7 Example - A Storage Allocator..................................................................................149
Appendix A - Reference Manual..........................................................................................154
A.1 Introduction..............................................................................................................154
A.2 Lexical Conventions..................................................................................................154
A.2.1 Tokens...............................................................................................................154
A.2.2 Comments..........................................................................................................154