<p style="MARGIN: 0px"> Introduction 1</p> <p style="MARGIN: 0px">1 Some Fundamentals 5</p> <p style="MARGIN: 0px"> Programming 5</p> <p style="MARGIN: 0px"> Higher-Level Languages 5</p> <p style="MARGIN: 0px"> Operating Systems 6</p> <p style="MARGIN: 0px"> Compiling Programs 7</p> <p style="MARGIN: 0px"> Integrated Development Environments 10</p> <p style="MARGIN: 0px"> Language Interpreters 10</p> <p style="MARGIN: 0px">2 Compiling and Running Your First Program 11</p> <p style="MARGIN: 0px"> Compiling Your Program 12</p> <p style="MARGIN: 0px"> Running Your Program 12</p> <p style="MARGIN: 0px"> Understanding Your First Program 13</p> <p style="MARGIN: 0px"> Displaying the Values of Variables 15</p> <p style="MARGIN: 0px"> Comments 17</p> <p style="MARGIN: 0px"> Exercises 19</p> <p style="MARGIN: 0px">3 Variables, Data Types, and Arithmetic Expressions 21</p> <p style="MARGIN: 0px"> Understanding Data Types and Constants 21</p> <p style="MARGIN: 0px"> The Integer Type int 22</p> <p style="MARGIN: 0px"> The Floating Number Type float 23</p> <p style="MARGIN: 0px"> The Extended Precision Type double 23</p> <p style="MARGIN: 0px"> The Single Character Type char 24</p> <p style="MARGIN: 0px"> The Boolean Data Type _Bool 24</p> <p style="MARGIN: 0px"> Type Specifiers: long, long long, short, unsigned, and signed 26</p> <p style="MARGIN: 0px"> Working with Variables 29</p> <p style="MARGIN: 0px"> Working with Arithmetic Expressions 30</p> <p style="MARGIN: 0px"> Integer Arithmetic and the Unary Minus Operator 33</p> <p style="MARGIN: 0px"> Combining Operations with Assignment: The Assignment Operators 39</p> <p style="MARGIN: 0px"> Types _Complex and _Imaginary 40</p> <p style="MARGIN: 0px"> Exercises 40</p> <p style="MARGIN: 0px">4 Program Looping 43</p> <p style="MARGIN: 0px"> Triangular Numbers 43</p> <p style="MARGIN: 0px"> The for Statement 44</p> <p style="MARGIN: 0px"> Relational Operators 46</p> <p style="MARGIN: 0px"> Aligning Output 50</p> <p style="MARGIN: 0px"> Program Input 51</p> <p style="MARGIN: 0px"> Nested for Loops 53</p> <p style="MARGIN: 0px"> for Loop Variants 55</p> <p style="MARGIN: 0px"> The while Statement 56</p> <p style="MARGIN: 0px"> The do Statement 60</p> <p style="MARGIN: 0px"> The break Statement 62</p> <p style="MARGIN: 0px"> The continue Statement 62</p> <p style="MARGIN: 0px"> Exercises 63</p> <p style="MARGIN: 0px">5 Making Decisions 65</p> <p style="MARGIN: 0px"> The if Statement 65</p> <p style="MARGIN: 0px"> The if-else Construct 69</p> <p style="MARGIN: 0px"> Compound Relational Tests 72</p> <p style="MARGIN: 0px"> Nested if Statements 74</p> <p style="MARGIN: 0px"> The else if Construct 76</p> <p style="MARGIN: 0px"> The switch Statement 83</p> <p style="MARGIN: 0px"> Boolean Variables 86</p> <p style="MARGIN: 0px"> The Conditional Operator 90</p> <p style="MARGIN: 0px"> Exercises 92</p> <p style="MARGIN: 0px">6 Working with Arrays 95</p> <p style="MARGIN: 0px"> Defining an Array 96</p> <p style="MARGIN: 0px"> Using Array Elements as Counters 100</p> <p style="MARGIN: 0px"> Generating Fibonacci Numbers 103</p> <p style="MARGIN: 0px"> Using an Array to Generate Prime Numbers 104</p> <p style="MARGIN: 0px"> Initializing Arrays 106</p> <p style="MARGIN: 0px"> Character Arrays 108</p> <p style="MARGIN: 0px"> Base Conversion Using Arrays 109</p> <p style="MARGIN: 0px"> The const Qualifier 111</p> <p style="MARGIN: 0px"> Multidimensional Arrays 113</p> <p style="MARGIN: 0px"> Variable Length Arrays 115</p> <p style="MARGIN: 0px"> Exercises 117</p> <p style="MARGIN: 0px">7 Working with Functions 119</p> <p style="MARGIN: 0px"> Defining a Function 119</p> <p style="MARGIN: 0px"> Arguments and Local Variables 123</p> <p style="MARGIN: 0px"> Function Prototype Declaration 124</p> <p style="MARGIN: 0px"> Automatic Local Variables 124</p> <p style="MARGIN: 0px"> Returning Function Results 126</p> <p style="MARGIN: 0px"> Functions Calling Functions Calling... 130</p> <p style="MARGIN: 0px"> Declaring Return Types and Argument Types 133</p> <p style="MARGIN: 0px"> Checking Function Arguments 135</p> <p style="MARGIN: 0px"> Top-Down Programming 137</p> <p style="MARGIN: 0px"> Functions and Arrays 137</p> <p style="MARGIN: 0px"> Assignment Operators 141</p> <p style="MARGIN: 0px"> Sorting Arrays 143</p> <p style="MARGIN: 0px"> Multidimensional Arrays 146</p> <p style="MARGIN: 0px"> Global Variables 151</p> <p style="MARGIN: 0px"> Automatic and Static Variables 155</p> <p style="MARGIN: 0px"> Recursive Functions 158</p> <p style="MARGIN: 0px"> Exercises 161</p> <p style="MARGIN: 0px">8 Working with Structures 163</p> <p style="MARGIN: 0px"> The Basics of Structures 163</p> <p style="MARGIN: 0px"> A Structure for Storing the Date 164</p> <p style="MARGIN: 0px"> Using Structures in Expressions 166</p> <p style="MARGIN: 0px"> Functions and Structures 169</p> <p style="MARGIN: 0px"> A Structure for Storing the Time 175</p> <p style="MARGIN: 0px"> Initializing Structures 178</p> <p style="MARGIN: 0px"> Compound Literals 178</p> <p style="MARGIN: 0px"> Arrays of Structures 180</p> <p style="MARGIN: 0px"> Structures Containing Structures 183</p> <p style="MARGIN: 0px"> Structures Containing Arrays 185</p> <p style="MARGIN: 0px"> Structure Variants 189</p> <p style="MARGIN: 0px"> Exercises 190</p> <p style="MARGIN: 0px">9 Character Strings 193</p> <p style="MARGIN: 0px"> Revisiting the Basics of Strings 193</p> <p style="MARGIN: 0px"> Arrays of Characters 194</p> <p style="MARGIN: 0px"> Variable-Length Character Strings 197</p> <p style="MARGIN: 0px"> Initializing and Displaying Character Strings 199</p> <p style="MARGIN: 0px"> Testing Two Character Strings for Equality 202</p> <p style="MARGIN: 0px"> Inputting Character Strings 204</p> <p style="MARGIN: 0px"> Single-Character Input 206</p> <p style="MARGIN: 0px"> The Null String 211</p> <p style="MARGIN: 0px"> Escape Characters 215</p> <p style="MARGIN: 0px"> More on Constant Strings 217</p> <p style="MARGIN: 0px"> Character Strings, Structures, and Arrays 218</p> <p style="MARGIN: 0px"> A Better Search Method 221</p> <p style="MARGIN: 0px"> Character Operations 226</p> <p style="MARGIN: 0px"> Exercises 229</p> <p style="MARGIN: 0px">10 Pointers 233</p> <p style="MARGIN: 0px"> Pointers and Indirection 233</p> <p style="MARGIN: 0px"> Defining a Pointer Variable 234</p> <p style="MARGIN: 0px"> Using Pointers in Expressions 237</p> <p style="MARGIN: 0px"> Working with Pointers and Structures 239</p> <p style="MARGIN: 0px"> Structures Containing Pointers 241</p> <p style="MARGIN: 0px"> Linked Lists 243</p> <p style="MARGIN: 0px"> The Keyword const and Pointers 251</p> <p style="MARGIN: 0px"> Pointers and Functions 252</p> <p style="MARGIN: 0px"> Pointers and Arrays 258</p> <p style="MARGIN: 0px"> A Slight Digression About Program Optimization 262</p> <p style="MARGIN: 0px"> Is It an Array or Is It a Pointer? 262</p> <p style="MARGIN: 0px"> Pointers to Character Strings 264</p> <p style="MARGIN: 0px"> Constant Character Strings and Pointers 266</p> <p style="MARGIN: 0px"> The Increment and Decrement Operators Revisited 267</p> <p style="MARGIN: 0px"> Operations on Pointers 271</p> <p style="MARGIN: 0px"> Pointers to Functions 272</p> <p style="MARGIN: 0px"> Pointers and Memory Addresses 273</p> <p style="MARGIN: 0px"> Exercises 275</p> <p style="MARGIN: 0px">11 Operations on Bits 277</p> <p style="MARGIN: 0px"> The Basics of Bits 277</p> <p style="MARGIN: 0px"> Bit Operators 278</p> <p style="MARGIN: 0px"> The Bitwise AND Operator 279</p> <p style="MARGIN: 0px"> The Bitwise Inclusive-OR Operator 281</p> <p style="MARGIN: 0px"> The Bitwise Exclusive-OR Operator 282</p> <p style="MARGIN: 0px"> The Ones Complement Operator 283</p> <p style="MARGIN: 0px"> The Left Shift Operator 285</p> <p style="MARGIN: 0px"> The Right Shift Operator 286</p> <p style="MARGIN: 0px"> A Shift Function 286</p> <p style="MARGIN: 0px"> Rotating Bits 288</p> <p style="MARGIN: 0px"> Bit Fields 291</p> <p style="MARGIN: 0px"> Exercises 295</p> <p style="MARGIN: 0px">12 The Preprocessor 297</p> <p style="MARGIN: 0px"> The #define Statement 297</p> <p style="MARGIN: 0px"> Program Extendability 301</p> <p style="MARGIN: 0px"> Program Portability 302</p> <p style="MARGIN: 0px"> More Advanced Types of Definitions 304</p> <p style="MARGIN: 0px"> The # Operator 309</p> <p style="MARGIN: 0px"> The ## Operator 310</p> <p style="MARGIN: 0px"> The #include Statement 311</p> <p style="MARGIN: 0px"> System Include Files 313</p> <p style="MARGIN: 0px"> Conditional Compilation 314</p> <p style="MARGIN: 0px"> The #ifdef, #endif, #else, and #ifndef Statements 314</p> <p style="MARGIN: 0px"> The #if and #elif Preprocessor Statements 316</p> <p style="MARGIN: 0px"> The #undef Statement 317</p> <p style="MARGIN: 0px"> Exercises 318</p> <p style="MARGIN: 0px">13 Extending Data Types with the Enumerated Data Type, Type Definitions, and Data Type Conversions 319</p> <p style="MARGIN: 0px"> Enumerated Data Types 319</p> <p style="MARGIN: 0px"> The typedef Statement 323</p> <p style="MARGIN: 0px"> Data Type Conversions 325</p> <p style="MARGIN: 0px"> Sign Extension 327</p> <p style="MARGIN: 0px"> Argument Conversion 328</p> <p style="MARGIN: 0px"> Exercises 329</p> <p style="MARGIN: 0px">14 Working with Larger Programs 331</p> <p style="MARGIN: 0px"> Dividing Your Program into Multiple Files 331</p> <p style="MARGIN: 0px"> Compiling Multiple Source Files from the Command Line 332</p> <p style="MARGIN: 0px"> Communication Between Modules 334</p> <p style="MARGIN: 0px"> External Variables 334</p> <p style="MARGIN: 0px"> Static Versus Extern Variables and Functions 337</p> <p style="MARGIN: 0px"> Using Header Files Effectively 339</p> <p style="MARGIN: 0px"> Other Utilities for Working with Larger Programs 341</p> <p style="MARGIN: 0px"> The make Utility 341</p> <p style="MARGIN: 0px"> The cvs Utility 343</p> <p style="MARGIN: 0px"> Unix Utilities: ar, grep, sed, and so on 343</p> <p style="MARGIN: 0px">15 Input and Output Operations in C 345</p> <p style="MARGIN: 0px"> Character I/O: getchar() and putchar() 346</p> <p style="MARGIN: 0px"> Formatted I/O: printf() and scanf() 346</p> <p style="MARGIN: 0px"> The printf() Function 346</p> <p style="MARGIN: 0px"> The scanf() Function 353</p> <p style="MARGIN: 0px"> Input and Output Operations with Files 358</p> <p style="MARGIN: 0px"> Redirecting I/O to a File 358</p> <p style="MARGIN: 0px"> End of File 361</p> <p style="MARGIN: 0px"> Special Functions for Working with Files 362</p> <p style="MARGIN: 0px"> The fopen Function 362</p> <p style="MARGIN: 0px"> The getc() and putc() Functions 364</p> <p style="MARGIN: 0px"> The fclose() Function 365</p> <p style="MARGIN: 0px"> The feof Function 367</p> <p style="MARGIN: 0px"> The fprintf() and fscanf() Functions 367</p> <p style="MARGIN: 0px"> The fgets() and fputs() Functions 367</p> <p style="MARGIN: 0px"> stdin, stdout, and stderr 368</p> <p style="MARGIN: 0px"> The exit() Function 369</p> <p style="MARGIN: 0px"> Renaming and Removing Files 370</p> <p style="MARGIN: 0px"> Exercises 371</p> <p style="MARGIN: 0px">16 Miscellaneous and Advanced Features 373</p> <p style="MARGIN: 0px"> Miscellaneous Language Statements 373</p> <p style="MARGIN: 0px"> The goto Statement 373</p> <p style="MARGIN: 0px"> The null Statement 374</p> <p style="MARGIN: 0px"> Working with Unions 375</p> <p style="MARGIN: 0px"> The Comma Operator 378</p> <p style="MARGIN: 0px"> Type Qualifiers 379</p> <p style="MARGIN: 0px"> The register Qualifier 379</p> <p style="MARGIN: 0px"> The volatile Qualifier 379</p> <p style="MARGIN: 0px"> The restrict Qualifier 379</p> <p style="MARGIN: 0px"> Command-line Arguments 380</p> <p style="MARGIN: 0px"> Dynamic Memory Allocation 384</p> <p style="MARGIN: 0px"> The calloc() and malloc() Functions 385</p> <p style="MARGIN: 0px"> The sizeof Operator 385</p> <p style="MARGIN: 0px"> The free Function 387</p> <p style="MARGIN: 0px"> Exercises 389</p> <p style="MARGIN: 0px">17 Debugging Programs 391</p> <p style="MARGIN: 0px"> Debugging with the Preprocessor 391</p> <p style="MARGIN: 0px"> Debugging Programs with gdb 397</p> <p style="MARGIN: 0px"> Working with Variables 400</p> <p style="MARGIN: 0px"> Source File Display 401</p> <p style="MARGIN: 0px"> Controlling Program Execution 402</p> <p style="MARGIN: 0px"> Getting a Stack Trace 406</p> <p style="MARGIN: 0px"> Calling Functions and Setting Arrays and Structures 407</p> <p style="MARGIN: 0px"> Getting Help with gdb Commands 408</p> <p style="MARGIN: 0px"> Odds and Ends 410</p> <p style="MARGIN: 0px">18 Object-Oriented Programming 413</p> <p style="MARGIN: 0px"> What Is an Object Anyway? 413</p> <p style="MARGIN: 0px"> Instances and Methods 414</p> <p style="MARGIN: 0px"> Writing a C Program to Work with Fractions 416</p> <p style="MARGIN: 0px"> Defining an Objective-C Class to Work with Fractions 417</p> <p style="MARGIN: 0px"> Defining a C++ Class to Work with Fractions 421</p> <p style="MARGIN: 0px"> Defining a C# Class to Work with Fractions 424</p> <p style="MARGIN: 0px">A C Language Summary 427</p> <p style="MARGIN: 0px">B The Standard C Library 471</p> <p style="MARGIN: 0px">C Compiling Programs with gcc 495</p> <p style="MARGIN: 0px">D Common Programming Mistakes 499</p> <p style="MARGIN: 0px">E Resources 505</p> <p style="MARGIN: 0px">TOC, 9780321776419, 7/28/2014</p> <p style="MARGIN: 0px"> </p>