the art of c programming - d-nb.info
Post on 30-Jan-2022
0 Views
Preview:
TRANSCRIPT
Robin Jones lan Stewart
The Art of C Programming
With 42 Illustrations
Springer-Verlag New York Berlin Heidelberg
London Paris Tokyo
Contents
Preface vii
CHAPTER 1 Compilers and Interpreters 1
Editors 2 The Compilation Process 2
CHAPTER 2 The Skeleton of a C Program 5
Plus ca Change ... 6 Vive la Difference 7 Simple and Compound Statements 7 Functions That Don't Return Values 8 Returning Values 9 Main 9 Variable Types 10 Variable Scope 11 Global Variables 11 Loose Ends 12 printf 13 Comments 13
CHAPTER 3 Loops and Control Constructs 15
If 15 Conditional Expressions 16 Logical Connectives 17 Loops 17 while 17 Autoincrements 18 The sqr Function 19 do-while 22 for loops 23
x Contents
CHAPTER 4 Arithmetic and Logic
Odds and Evens Logical Operators ASCII Code AND OR XOR NOT Shifts
CHAPTER 5 Strings, Arrays, and Pointers
Strings and Pointers Arrays Declaring Arrays String Functions Left-Hand Bit Right a Bit More about Pointers Left Again Further Right Copycat
CHAPTER 6 Floats and Other Types
float double Qualifiers for int Signs and Shifts Register Variables Declaring Structures Defining Your Own Types Constants and Initializers Character Constants Handling Control Characters Defining Your Own Constants Variable Constants # include Octal and Hexadecimal Constants Initializers Initializing Pointers Declaring Function Types
Contents XI
CHAPTER 7 Input 57
Primitive Input 57 Get a Bufierfull 57 Operator Precedence 59 Strings to Numbers 60 A Feeble Excuse 63 scanf 64
CHAPTER 8 Output 66
More about printf 67 Justification 67 Printing to Memory 67 Primitive Output 68
CHAPTER 9 More About Control Constructs 70
The Conditional Operator 70 Leaping out of Loops 71 Continuing 71 Multiway Switches 72 Do Not Pass Go 73
CHAPTER 10 Recursion 75
Factorials 76 Things with Strings 77 Back-to-Front Sentences 79 In and Out 80 Reversing the Text 81 Postscript 83
CHAPTER 11 Structures 84
Playing with Structures 85 The Storeman's Mate 86 Delete 88 Add 89 Recursive Structures 90
xii Contents
CHAPTER 12 File-handling 93
I/O Redirection 94 Error Messages 94 Buffered File I/O 95 fopen 95 Creating a File 96 Once More, with Filing 97 File Access Errors 98 Random Access Files 99 The Square Table 100 Second Attempt 100 Reversing the Process 101
CHAPTER 13 Debugging 106
Common Errors 107 Runtime Errors 108 Testing a Function 109 Test Lines 110 BeThorough 112 Dormant Bugs 113
CHAPTER 14 Rational Arithmetic 117
Fixing the Problem 118 Overflow 119 A Practical Organization 120 Functions 121 Double or Nothing 122 Portability Considerations 125 Lies, Damned Lies and Computer Programs 126 Subtraction 126 Multiplication 127 Division 127 The Conversion Routines 127 And Now the Bad News ... 129 Postscript 131
CHAPTER 15 Implementing Turtle Graphics... 132
Turning Turtle 133 But First, The Snags ... 134 Triggery—Pokery 134 The Turtle Commands 137 Turtle Incorporated 139
Contents xui
Seeketh after a Sine 140 A Trig Suite in C 143
CHAPTER 16 . . . and Using Them 145
Rectangles 146 Fan-Dancing 147 Polygons 149 Circle 151 Stars 151 Spirals 151 The Koch Snowflake 152 Afterthoughts... 155
CHAPTER 17 Random Thoughts 157
Some Basic Ideas 158 Testing "Randomness" 159 The Numerical Connection 160 Linear Feedback Shift Registers 162 A Practical Program 163
APPENDIX 1 Loose Ends 169
APPENDIX 2 Quick Reference Guide 176
Index 183
top related