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