Details

C Programming For Dummies


C Programming For Dummies


2. Aufl.

von: Dan Gookin

22,99 €

Verlag: Wiley
Format: PDF
Veröffentl.: 29.09.2020
ISBN/EAN: 9781119740254
Sprache: englisch
Anzahl Seiten: 464

DRM-geschütztes eBook, Sie benötigen z.B. Adobe Digital Editions und eine Adobe ID zum Lesen.

Beschreibungen

<p><b>Get an A grade in C</b></p> <p>As with any major language, mastery of C can take you to some <i>very</i> interesting new places. Almost 50 years after it first appeared, it's still the world's most popular programming language and is used as the basis of global industry's core systems, including operating systems, high-performance graphics applications, and microcontrollers. This means that fluent C users are in big demand at the sharp end in cutting-edge industries—such as gaming, app development, telecommunications, engineering, and even animation—to translate innovative ideas into a smoothly functioning reality.</p> <p>To help you get to where you want to go with C, this 2nd edition of <i>C Programming For Dummies</i> covers everything you need to begin writing programs, guiding you logically through the development cycle: from initial design and testing to deployment and live iteration. By the end you'll be <i>au fait</i> with the do's and don'ts of good clean writing and easily able to produce the basic—and not-so-basic—building blocks of an elegant and efficient source code.</p> <ul> <li>Write and compile source code</li> <li>Link code to create the executable program</li> <li>Debug and optimize your code</li> <li>Avoid common mistakes</li> </ul> <p>Whatever your destination: tech industry, start-up, or just developing for pleasure at home, this easy-to-follow, informative, and entertaining guide to the C programming language is the fastest and friendliest way to get there!</p>
<p><b>Introduction</b><b> 1</b></p> <p>Why the C Language? 1</p> <p>The C Programming For Dummies Approach 2</p> <p>How This Book Works 3</p> <p>Icons Used in This Book 4</p> <p>Parting Thoughts 5</p> <p><b>Part 1: The ABs of C 7</b></p> <p><b>Chapter 1: A Quick Start for the Impatient</b><b> 9</b></p> <p>What You Need to Program 9</p> <p>Command Prompt Programming 10</p> <p>IDE Programming 11</p> <p>Installing Code::Blocks 12</p> <p>Touring the Code::Blocks workspace 13</p> <p>Your First Program 14</p> <p>Coding at the command prompt 15</p> <p>Building a new Code::Blocks project 16</p> <p>Building and running 18</p> <p><b>Chapter 2: The Programming Thing</b><b> 21</b></p> <p>The History of Programming 21</p> <p>Reviewing early programming history 21</p> <p>Introducing the C language 22</p> <p>The Programming Process 23</p> <p>Understanding programming 23</p> <p>Writing source code 24</p> <p>Compiling and linking 26</p> <p>Running and testing 27</p> <p><b>Chapter 3: Anatomy of C</b><b> 29</b></p> <p>Parts of the C Language 29</p> <p>Keywords 30</p> <p>Functions 31</p> <p>Operators 33</p> <p>Variables and values 33</p> <p>Statements and structure 33</p> <p>Comments 35</p> <p>Behold the Typical C Program 37</p> <p>Understanding C program structure 37</p> <p>Setting the main() function 38</p> <p>Returning something to the operating system 39</p> <p>Adding a function 40</p> <p><b>Part 2: C Programming 101 43</b></p> <p><b>Chapter 4: Trials and Errors</b><b> 45</b></p> <p>Display Stuff on the Screen 45</p> <p>Displaying a humorous message 45</p> <p>Introducing the <i>puts() </i>function 46</p> <p>Adding more text 47</p> <p>Commenting out a statement 49</p> <p>Goofing up on purpose 49</p> <p>More Text Output Nonsense 51</p> <p>Displaying text with <i>printf()</i> 52</p> <p>Introducing the <i>printf() </i>function 52</p> <p>Understanding the newline 53</p> <p>Employing escape sequences 54</p> <p>Goofing up on purpose again 55</p> <p><b>Chapter 5: Values and Simple Math</b><b> 57</b></p> <p>A Venue for Various Values 57</p> <p>Understanding values 58</p> <p>Displaying values with <i>printf() </i>59</p> <p>Minding the extra zeros 61</p> <p>The Computer Does the Math 61</p> <p>Doing simple arithmetic 61</p> <p>Reviewing the float-integer thing 63</p> <p>Pretending integers are floats 64</p> <p><b>Chapter 6: A Place to Put Stuff</b><b> 67</b></p> <p>Values That Vary 67</p> <p>Setting up a quick example 68</p> <p>Introducing data types 69</p> <p>Using variables 70</p> <p>Variable Madness! 73</p> <p>Using more-specific data types 73</p> <p>Working with several variables 75</p> <p>Assigning a value upon creation 77</p> <p>Reusing variables 77</p> <p>Constants Always the Same 79</p> <p>Using the same value over and over 79</p> <p>Constants in your code 80</p> <p>Putting constants to use 81</p> <p><b>Chapter 7: Input and Output</b><b> 83</b></p> <p>Character I/O 83</p> <p>Understanding input and output devices 83</p> <p>Fetching characters with <i>getchar()</i> 84</p> <p>Using the <i>putchar() </i>function 86</p> <p>Working with character variables 87</p> <p>Text I/O, but Mostly I 88</p> <p>Storing strings 89</p> <p>Introducing the <i>scanf() </i>function 90</p> <p>Reading a string with <i>scanf()</i> 91</p> <p>Reading values with <i>scanf() </i>93</p> <p>Using <i>fgets() </i>for text input 94</p> <p><b>Chapter 8: Decision Making</b><b> 97</b></p> <p>What If? 97</p> <p>Making a simple comparison 97</p> <p>Introducing the <i>if </i>keyword 99</p> <p>Comparing values in various ways 100</p> <p>Knowing the difference between = and == 102</p> <p>Forgetting where to put the semicolon 103</p> <p>Multiple Decisions 104</p> <p>Making more-complex decisions 104</p> <p>Adding a third option 105</p> <p>Multiple Comparisons with Logic 106</p> <p>Building a logical comparison 106</p> <p>Adding some logical operators 107</p> <p>The Old <i>Switch Case </i>Trick 108</p> <p>Making a multiple-choice selection 108</p> <p>Understanding the <i>switch-case </i>structure 110</p> <p>Taking no breaks 111</p> <p>The Weird ?: Decision Thing 112</p> <p><b>Chapter 9: Loops, Loops, Loops</b><b> 115</b></p> <p>A Little Déjà Vu 115</p> <p>The Thrill of <i>for </i>Loops 116</p> <p>Doing something x number of times 116</p> <p>Introducing the <i>for </i>loop 117</p> <p>Counting with the <i>for </i>statement 119</p> <p>Looping letters 120</p> <p>Nesting <i>for </i>loops 121</p> <p>The Joy of the <i>while </i>Loop 123</p> <p>Structuring a <i>while </i>loop 123</p> <p>Using the <i>do while </i>loop 125</p> <p>Loopy Stuff 126</p> <p>Looping endlessly 126</p> <p>Looping endlessly but on purpose 127</p> <p>Breaking out of a loop 128</p> <p>Adding multiple <i>for </i>loop conditions 129</p> <p>Screwing up a loop 130</p> <p><b>Chapter 10: Fun with Functions</b><b> 133</b></p> <p>Anatomy of a Function 133</p> <p>Constructing a function 133</p> <p>Prototyping (or not) 136</p> <p>Functions and Variables 139</p> <p>Using variables in functions 139</p> <p>Sending a value to a function 140</p> <p>Sending multiple values to a function 142</p> <p>Creating functions that return values 143</p> <p>Returning early 145</p> <p>Constants of the Global Kind 147</p> <p>Introducing defined constants 147</p> <p>Putting defined constants to use 148</p> <p><b>Part 3: Build Upon What You Know 151</b></p> <p><b>Chapter 11: The Unavoidable Math Chapter</b><b> 153</b></p> <p>Math Operators from Beyond Infinity 153</p> <p>Incrementing and decrementing 154</p> <p>Prefixing the ++ and -- operators 156</p> <p>Discovering the remainder (modulus) 158</p> <p>Saving time with assignment operators 158</p> <p>Math Function Mania 160</p> <p>Exploring some common math functions 161</p> <p>Suffering through trigonometry 163</p> <p>It’s Totally Random 166</p> <p>Spewing random numbers 166</p> <p>Making the numbers more random 167</p> <p>The Holy Order of Precedence 170</p> <p>Getting the order correct 170</p> <p>Forcing order with parentheses 171</p> <p><b>Chapter 12: Give Me Arrays</b><b> 173</b></p> <p>Behold the Array 173</p> <p>Avoiding arrays 173</p> <p>Understanding arrays 174</p> <p>Initializing an array 177</p> <p>Playing with character arrays (strings) 177</p> <p>Working with empty <i>char </i>arrays 179</p> <p>Sorting arrays 181</p> <p>Multidimensional Arrays 183</p> <p>Making a two-dimensional array 183</p> <p>Going crazy with three-dimensional arrays 186</p> <p>Declaring an initialized multidimensional array 188</p> <p>Arrays and Functions 189</p> <p>Passing an array to a function 189</p> <p>Returning an array from a function 191</p> <p><b>Chapter 13: Fun with Text</b><b> 193</b></p> <p>Character Manipulation Functions 193</p> <p>Introducing the CTYPEs 193</p> <p>Testing characters 195</p> <p>Changing characters 197</p> <p>String Functions Galore 198</p> <p>Reviewing string functions 198</p> <p>Comparing text 199</p> <p>Building strings 200</p> <p>Fun with <i>printf() </i>Formatting 202</p> <p>Formatting floating point 202</p> <p>Setting the output width 204</p> <p>Aligning output 206</p> <p>Gently Down the Stream 207</p> <p>Demonstrating stream input 207</p> <p>Dealing with stream input 208</p> <p><b>Chapter 14: Structures, the Multivariable</b><b> 211</b></p> <p>Hello, Structure 211</p> <p>Introducing the multivariable 211</p> <p>Understanding <i>struct</i> 213</p> <p>Filling a structure 215</p> <p>Making an array of structures 216</p> <p>Weird Structure Concepts 218</p> <p>Putting structures within structures 218</p> <p>Passing a structure to a function 219</p> <p><b>Chapter 15: Life at the Command Prompt</b><b> 221</b></p> <p>Conjure a Terminal Window 221</p> <p>Starting a terminal window 222</p> <p>Running code in text mode 223</p> <p>Arguments for the <i>main() </i>Function 225</p> <p>Reading the command line 225</p> <p>Understanding <i>main()’s </i>arguments 227</p> <p>Time to Bail 229</p> <p>Quitting the program 229</p> <p>Running another program 230</p> <p><b>Chapter 16: Variable Nonsense</b><b> 233</b></p> <p>Variable Control 233</p> <p>Typecasting into disbelief 233</p> <p>Creating new things with <i>typedef</i> 235</p> <p>Making <i>static </i>variables 238</p> <p>Variables, Variables Everywhere 241</p> <p>Using external variables 241</p> <p>Creating an external structure variable 243</p> <p>Enumerating 245</p> <p><b>Chapter 17: Binary Mania</b><b> 249</b></p> <p>Binary Basics 249</p> <p>Understanding binary 249</p> <p>Outputting binary values 251</p> <p>Bit Manipulation 253</p> <p>Using the bitwise | operator 253</p> <p>Using bitwise & 256</p> <p>Operating exclusively with XOR 257</p> <p>Understanding the ~ and ! operators 259</p> <p>Shifting binary values 259</p> <p>Explaining the binbin() function 263</p> <p>The Joy of Hex 264</p> <p><b>Part 4: The Advanced Part 267</b></p> <p><b>Chapter 18: Introduction to Pointers </b><b>269</b></p> <p>The Biggest Problem with Pointers 269</p> <p>Sizing Up Variable Storage 270</p> <p>Understanding variable storage 270</p> <p>Reading a variable’s size 271</p> <p>Checking a variable’s location 275</p> <p>Reviewing variable storage info 278</p> <p>The Hideously Complex Topic of Pointers 279</p> <p>Introducing the pointer 279</p> <p>Working with pointers 282</p> <p><b>Chapter 19: Deep into Pointer Land</b><b> 285</b></p> <p>Pointers and Arrays 285</p> <p>Getting the address of an array 285</p> <p>Working pointer math in an array 287</p> <p>Substituting pointers for array notation 293</p> <p>Strings Are Pointer-Things 294</p> <p>Using pointers to display a string 294</p> <p>Using a pointer to declare a string 295</p> <p>Building an array of pointers 296</p> <p>Sorting strings 300</p> <p>Pointers in Functions 302</p> <p>Passing a pointer to a function 302</p> <p>Returning a pointer from a function 303</p> <p><b>Chapter 20: Memory Chunks and Linked Lists</b><b> 305</b></p> <p>Give Me Memory! 306</p> <p>Introducing the malloc() function 306</p> <p>Creating string storage 308</p> <p>Using the calloc() function 309</p> <p>Getting more memory 311</p> <p>Freeing memory 313</p> <p>Lists That Link 314</p> <p>Allocating space for a structure 314</p> <p>Creating a linked list 316</p> <p>Editing a linked list 323</p> <p>Saving a linked list 328</p> <p><b>Chapter 21: It’s About Time</b><b> 329</b></p> <p>What Time is It? 329</p> <p>Understanding the calendar 330</p> <p>Working with time in C 330</p> <p>Time to Program 331</p> <p>Checking the clock 331</p> <p>Viewing a timestamp 333</p> <p>Slicing through the time string 334</p> <p>Snoozing 336</p> <p><b>Part 5: And the Rest of It 337</b></p> <p><b>Chapter 22: Permanent Storage Functions</b><b> 339</b></p> <p>Sequential File Access 339</p> <p>Understanding C file access 340</p> <p>Writing text to a file 341</p> <p>Reading text from a file 342</p> <p>Appending text to a file 345</p> <p>Writing binary data 346</p> <p>Reading binary data 348</p> <p>Random File Access 350</p> <p>Writing a structure to a file 351</p> <p>Reading and rewinding 353</p> <p>Finding a specific record 355</p> <p>Saving a linked list to a file 357</p> <p><b>Chapter 23: File Management</b><b> 359</b></p> <p>Directory Madness 359</p> <p>Calling up a directory 359</p> <p>Gathering more file info 361</p> <p>Separating files from directories 363</p> <p>Exploring the directory tree 364</p> <p>Fun with Files 365</p> <p>Renaming a file 365</p> <p>Copying a file 367</p> <p>Deleting a file 368</p> <p><b>Chapter 24: Beyond Mere Mortal Projects</b><b> 369</b></p> <p>The Multi-Module Monster 369</p> <p>Linking two source code files 370</p> <p>Sharing variables between modules 372</p> <p>Creating a custom header file 374</p> <p>Other Libraries to Link 378</p> <p><b>Chapter 25: Out, Bugs!</b><b> 381</b></p> <p>Simple Tricks to Resolve Problems 381</p> <p>Documenting the flow 382</p> <p>Talking through your code 382</p> <p>Writing comments for future-you 382</p> <p>The Debugger 383</p> <p>Debugging setup 383</p> <p>Working the debugger 385</p> <p>Setting a breakpoint 387</p> <p>Watching variables 388</p> <p>Improved Error Messages 390</p> <p><b>Part 6: The Part of Tens 393</b></p> <p><b>Chapter 26: Ten Common Boo-Boos</b><b> 395</b></p> <p>Conditional Foul-Ups 395</p> <p>== v = 396</p> <p>Dangerous Loop Semicolons 397</p> <p>Commas in <i>for </i>Loops 398</p> <p>Missing break in a switch Structure 398</p> <p>Missing Parentheses and Curly Brackets 399</p> <p>Don’t Ignore a Warning 399</p> <p>Endless Loops 400</p> <p><i>scanf() </i>Blunders 401</p> <p>Streaming Input Restrictions 402</p> <p><b>Chapter 27: Ten Reminders and Suggestions</b><b> 403</b></p> <p>Maintain Good Posture 404</p> <p>Use Creative Names 404</p> <p>Write a Function 405</p> <p>Work on Your Code a Little Bit at a Time 405</p> <p>Break Apart Larger Projects into Several Modules 406</p> <p>Know What a Pointer is 406</p> <p>Add Whitespace before Condensing 407</p> <p>Know When <i>if-else </i>Becomes <i>switch-case </i>407</p> <p>Remember Assignment Operators 408</p> <p>When You Get Stuck, Read Your Code Out Loud 409</p> <p><b>Part 7: Appendices</b><b> 411</b></p> <p><b>Appendix A: ASCII Codes 413</b></p> <p><b>Appendix B: Keywords 419</b></p> <p><b>Appendix C: Operators 421</b></p> <p><b>Appendix D: Data Types 423</b></p> <p><b>Appendix E: Escape Sequences 425</b></p> <p><b>Appendix F: Conversion Characters 427</b></p> <p><b>Appendix G: Order of Precedence 429</b></p> <p>Index 431</p>
<p><b>Dan Gookin</b> has been writing about technology for more than 30 years—and wrote the very first For Dummies book in 1991! Since then he's written gizmo- and tech innovation-focused bestseller after bestseller, including <i>Word 2019 For Dummies, Android For Dummies, 2nd Edition,</i> and many more!
<ul> <li>Discover C language and start coding in no time</li> <li>Build your knowledge to create advanced projects and programs</li> <li>Kickstart your new career as a C programmer</li> </ul> <p><b>Get an A grade in C</b> <p>Learning C can take you to some very interesting new places. Because it's the world's most popular programming language, fluent users are in high demand in cutting-edge industries, such as gaming, app development, telecomms, and even animation. This essential easy-to-follow, and fully updated resource covers everything you need to begin writing and applying good, clean code—from initial design and testing to deployment and live iteration. Whatever your destination with C, this is the fastest and friendliest way to get there. <p><b>Inside...</b> <ul> <li>Obtain free programming tools</li> <li>Create and debug code</li> <li>Explore text input and output</li> <li>Understand computer math</li> <li>Master data types</li> <li>Get friendly with pointers</li> <li>Explore files and structures</li> <li>Avoid silly mistakes</li> </ul>

Diese Produkte könnten Sie auch interessieren:

Domain Architectures
Domain Architectures
von: Daniel J. Duffy
PDF ebook
31,99 €