|
|
|
|
|
|
|
|
|
|
|
|
|
Contents in Detail...
1 Introduction 1
1.1 How to Proceed 1
1.2 Why use C? 4
1.3 Why use Unix? 9
Part i Introduction to Computers and Unix 19
2 Binary Information Systems 21
2.1 Why do I need to know this stuff? 21
2.2 Representing Information in Binary 21
3 Hardware and Software 41
3.1 What Makes Computers Tick? 41
3.2 The Main Components 41
3.3 Programs and Programming Languages 46
3.4 The Programming Process 49
4 Unix Overview 55
4.1 What is an Operating System? 55
4.2 The Unix Operating System 58
4.3 The Unix File-system 61
4.4 The Shell Environment 68
4.5 Getting Help 72
4.6 Some Useful Unix Commands 73
4.7 A Few Shortcuts with T-shell 78
4.8 Unix Input and Output 80
4.9 Job Control 86
4.10 Shell Variables and Environment Variables 88
4.11 Shell Scripts 89
4.12 Advanced: Make 91
Part ii Programming in C 95
5 Getting Started with C and Unix 97
5.1 What is C? 97
5.2 C Program Structure 98
5.3 A Word about Performance 101
5.4 Some Early Warnings 102
5.5 Coding and Compiling a C Program 102
6 Data Types 113
6.1 Introduction 113
6.2 Variables 114
6.3 C's Built-in Data Types 117
6.4 Constants 121
6.5 Initialization in Variable Definitions 126
6.6 Choosing the Right Data Type 127
6.7 Creating New Type Names: typedef 131
7 Simple Input and Output 133
7.1 The Standard I/O Streams 133
7.2 Single Character I/O 134
7.3 String I/O 135
7.4 Numeric I/O 137
7.5 Using fprintf() for Debugging 151
8 C Statements and Expressions 155
8.1 Simple Expressions 156
8.2 The C Operators 157
8.3 Mixed Expressions 165
9 Decisions with if and switch 175
9.1 Program Flow 175
9.2 Boolean Expressions 176
9.3 The if-else Statement 177
9.4 Switch 192
9.5 Advanced: The Conditional Operator 196
10 Repetition: Loops 199
10.1 The Universal Loop - while 201
10.2 The do-while Loop 205
10.3 The for Loop 207
10.4 Nested Loops 214
11 Functions 217
11.1 Subprograms for Modularity 217
11.2 Reusability and Encapsulation 219
11.3 Writing Functions 222
11.4 Local Variables 232
11.5 Arguments 234
11.6 Library Functions 239
11.7 Documenting Functions 240
11.8 Top-down Programming and Stubs 241
11.9 Advanced: Recursion 243
11.10 Advanced: Scope and Storage Class 246
11.11 Advanced: The inline Request 253
12 Programming with make 255
12.1 Using Separate Source Files 255
12.2 Using make 257
12.3 Using Header Files 259
12.4 Makefile Generators 259
13 The C Preprocessor: cpp 261
13.1 Macros and Constants: \#define 261
13.2 Functions vs. Macros 266
13.3 Header Files: \#include 272
13.4 Advanced: Conditional Compilation 274
13.5 Advanced: Other Directives 283
13.6 Advanced: The Paste Operator: \#\# 283
13.7 Advanced: Predefined Macros 284
14 Pointers 285
14.1 Pointers: This Stuff is BIG! 285
14.2 Pointer Basics 287
14.3 Defining Pointer Variables 287
14.4 Using Pointers: Indirection 288
14.5 Pointers as Function Arguments 293
14.6 Typedef and Pointers 297
15 Arrays and Strings 299
15.1 One Dimensional Arrays 299
15.2 Arrays and Pointers 309
15.3 Typedef and Arrays 317
15.4 Advanced: More Fun with Pointers 318
15.5 Arrays and Functions 319
15.6 Lookup tables 325
15.7 Pointer Arguments and const 326
15.8 Multi Dimensional Arrays 327
16 Dynamic Memory Allocation 333
16.1 Dynamic Allocation: malloc() and alloca() 333
16.2 Basic Usage 334
16.3 How malloc() Keeps Track: Heap Tables 341
16.4 Pointer Arrays 344
16.5 Pointer Arrays and Strings 350
16.6 Command Line Arguments: argv 354
16.7 The Environment: envp 357
17 Advanced: Function Pointers 361
17.1 Simple Function Pointers 361
17.2 Function Pointer Tables 363
18 Structures and Unions 367
18.1 Structures 367
18.2 Pointers to Structures 373
18.3 Structures, Functions, and OOP 374
18.4 Nesting Structures 380
18.5 Lists of Structures 382
18.6 Initializing Structures 393
18.7 Advanced: Unions 395
18.8 Advanced: Structure Alignment 400
18.9 Advanced: Bit Fields 403
19 Debugging 407
19.1 Thinkin' it Through 408
19.2 Making Programs Talk: Debug Code 408
19.3 Unix Debuggers: Which One? 412
19.4 The GNU Debugger: gdb 414
Part iii Unix Library Functions and Their Use 421
20 Building Object Code Libraries 425
20.1 Working with Libraries 425
21 Files and File Streams 431
21.1 FILE Streams 431
21.2 The FILE Structure 432
21.3 Basic Stream I/O Functions 433
21.4 Temporary files 445
21.5 Writing Filter Programs 448
21.6 Advanced: Controlling FILE streams 450
21.7 File Error Handling 457
21.8 Manipulating Whole Files 459
22 String and Character Functions 463
22.1 Basic String Manipulation 463
22.2 String Functions 465
22.3 Classifying Characters: The Ctype Functions 474
22.4 Pattern Matching Functions 476
22.5 Bulk Memory Manipulation 483
23 Odds and Ends 485
23.1 Math Functions 485
23.2 Data Conversion Functions 487
23.3 Random Numbers 489
23.4 Basic Process Control 490
23.5 Manipulating the Environment 491
23.6 Sorting and Searching 493
23.7 Functions with Variable Argument Lists 499
24 Working with the Unix Filesystem 505
24.1 File Information: stat() and fstat() 505
24.2 Changing File Information 507
24.3 Accessing Directories 509
25 Low-Level I/O 513
25.1 Why Use Low-level I/O? 513
25.2 Basic Input and Output 516
26 Controlling I/O Device Drivers 533
26.1 Termios 534
27 Unix Processes 543
27.1 Creating Processes 544
27.2 Redirection 551
28 Interprocess Communication (IPC) 559
28.1 The Environment 560
28.2 Signals 560
28.3 Pipes 563
28.4 Sockets 569
28.5 Shared Memory 584
28.6 Threads 591
29 Unix Graphics: X Windows 595
29.1 How X Windows Works 595
29.2 Programming with Xlib 597
29.3 Programming with the Xt toolkit 603
Part iv The C++ Programming Language 611
30 Introduction to C++ 613
30.1 Object Oriented Programming 613
30.2 Basic Terminology 614
30.3 Fundamental Syntactic Differences 615
30.4 Classes and Encapsulation 618
30.5 References 629
30.6 Dynamic Memory Allocation in C++ 633
30.7 Overloading and Templates 637
30.8 File I/O 645
30.9 Inheritance 647
30.10 Friend Classes 653
30.11 Conclusion 653
A GNU Sites 655
B News Groups 657
|