9780321884923

Learn C the Hard Way Practical Exercises on the Computational Subjects You Keep Avoiding (Like C)

by
  • ISBN13:

    9780321884923

  • ISBN10:

    0321884922

  • Edition: 1st
  • Format: Paperback
  • Copyright: 9/4/2015
  • Publisher: Addison-Wesley Professional

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping On Orders Over $59!
    Your order must be $59 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $39.99 Save up to $10.00
  • Rent Book $29.99
    Add to Cart Free Shipping

    TERM
    PRICE
    DUE

Supplemental Materials

What is included with this book?

  • The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.
  • The Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Summary

Need to learn C? Now you can! Forget old-fashioned C programming books that assume you're a computer hardware expert and teach frustrating, old-fashioned coding styles. If you know any language at all, Zed A. Shaw's Learn C the Hard Waycan help you get started fast with modern C programming. This book/CD package is called "The Hard Way," but it's really quite easy: it just requires discipline, practice, and persistence. Shaw teaches how to write modern, clean, clear C code through dozens of brilliantly-crafted exercises, most on two pages. You simply read each exercise, type in its sample code precisely (no copy-and-paste!), and make the programs run. As you read, type, fix your mistakes, and watch the results, you learn how C works… what good modern C programs look like… how to read, write, and "see" code… how to spot crucial differences that change or break programs… all the essentials of C logic, I/O, variables, and functions… and the attention to detail that is indispensable to successful C programming. At first, yes, it can be difficult. But it gets easier. And Shaw offers plenty of extra help through 5+ full hours of CD-based teaching video. Nothing important comes without discipline, practice, and persistence. But, with this package, if you bring those qualities, you willmaster C… and you willreap the very real personal and career rewards that go with C programming expertise!

Author Biography

Zed Shaw is an avid guitar player, programmer, and writer whose books teach people all over the world how to write software. His book Learn Python the Hard Way has been read by millions of people around the world. His software has been used by many large and small companies. His essays are often quoted and read by members of many geek communities. He is an entertaining and lively writer, who is sure to keep you laughing and make you think.

Table of Contents

I            Basic Skills

 

1                  Exercise 0: The Setup                 

1.1 Linux

1.2 MacOSX

1.3 Windows

1.4 TextEditor

1.4.1 WARNING:DoNotUseAnIDE

 

2                  Exercise 1: Dust Off That Compiler                 

2.1 WhatYouShouldSee

2.2 HowToBreakIt

2.3 ExtraCredit

 

3                  Exercise 2: Make Is Your Python Now                 

3.1 UsingMake

3.2 WhatYouShouldSee

3.3 HowToBreakIt

3.4 ExtraCredit

 

4                  Exercise 3: Formatted Printing                 

4.1 WhatYouShouldSee

4.2 ExternalResearch

4.3 HowToBreakIt

4.4 ExtraCredit

 

5                  Exercise 4: Introducing Valgrind                 

5.1 InstallingValgrind

5.2 UsingValgrind

5.3 WhatYouShouldSee

5.4 ExtraCredit

 

6                  Exercise 5: The Structure Of A C Program                 

6.1 WhatYouShouldSee

6.2 BreakingItDown

6.3 ExtraCredit

 

7                  Exercise 6: Types Of Variables                 

7.1 WhatYouShouldSee

7.2 HowToBreakIt

7.3 ExtraCredit

 

8                  Exercise 7: More Variables, Some Math                 

8.1 WhatYouShouldSee

8.2 HowToBreakIt

8.3 ExtraCredit

 

9                  Exercise 8: Sizes And Arrays

9.1 WhatYouShouldSee

9.2 HowToBreakIt

9.3 ExtraCredit

 

10 Exercise 9: Arrays And Strings                 

10.1WhatYouShouldSee

 10.2HowToBreakIt

10.3ExtraCredit

 

11 Exercise 10: Arrays Of Strings, Looping                 

11.1WhatYouShouldSee

11.1.1UnderstandingArraysOfStrings

11.2HowToBreakIt

11.3ExtraCredit

 

12 Exercise 11: While-Loop And Boolean Expressions                 

12.1WhatYouShouldSee

12.2HowToBreakIt

12.3ExtraCredit

 

13 Exercise 12: If, Else-If, Else                 

13.1WhatYouShouldSee

13.2HowToBreakIt

13.3ExtraCredit

 

14 Exercise 13: Switch Statement                 

14.1WhatYouShouldSee

14.2HowToBreakIt 

14.3ExtraCredit

 

15 Exercise 14: Writing And Using Functions                 

15.1WhatYouShouldSee

15.2HowToBreakIt

15.3ExtraCredit  

 

16 Exercise 15: Pointers Dreaded Pointers                 

16.1WhatYouShouldSee

16.2ExplainingPointers 

16.3PracticalPointerUsage

 

16.4ThePointerLexicon

16.5PointersAreNotArrays

16.6HowToBreakIt

16.7ExtraCredit

 

17 Exercise 16: Structs And Pointers To Them                 

17.1WhatYouShouldSee

17.2ExplainingStructures

17.3HowToBreakIt

17.4ExtraCredit  

 

18 Exercise 17: Heap And Stack Memory Allocation                 

18.1WhatYouShouldSee

18.2Heapvs.StackAllocation

18.3HowToBreakIt

 

18.4ExtraCredit

 

19 Exercise 18: Pointers To Functions                 

19.1WhatYouShouldSee

19.2HowToBreakIt

 

19.3ExtraCredit

 

20 Exercise 19: A Simple Object System                 

20.1HowTheCPPWorks

20.2ThePrototypeObjectSystem

20.2.1TheObjectHeaderFile

20.2.2TheObjectSourceFile

20.3TheGameImplementation

20.4WhatYouShouldSee

20.5AuditingTheGame

20.6ExtraCredit

 

21 Exercise 20: Zed’s Awesome Debug Macros                 

21.1TheCErrorHandlingProblem

21.2TheDebugMacros

21.3 Using dbg.h

21.4 What You Should See

21.5HowTheCPPExpandsMacros

21.6ExtraCredit

 

22 Exercise 21: Advanced Data Types And Flow Control                 

22.1AvailableDataTypes

22.1.1TypeModifiers

22.1.2TypeQualifiers

22.1.3TypeConversion

22.1.4TypeSizes

22.2 Available Operators

22.2.1MathOperators

22.2.2DataOperators

22.2.3 Logic Operators

22.2.4 Bit Operators

22.2.5BooleanOperators

22.2.6AssignmentOperators

22.3 Available Control Structures

22.3.1ExtraCredit

 

23 Exercise 22: The Stack, Scope, And Globals                 

23.0.2 ex22.h and ex22.c

23.0.3ex22_main.c

23.1 What You Should See

23.2 Scope, Stack, And Bugs

23.3 How To Break It

23.4ExtraCredit

 

24 Exercise 23: Meet Duff’s Device                 

24.1 What You Should See

.2SolvingThePuzzle

24.2.1 Why Bother?

24.3ExtraCredit

 

25 Exercise 24: Input, Output, Files                 

25.1 What You Should See

25.2 How To Break It

25.3 The I/O Functions

25.4ExtraCredit

 

26 Exercise 25: Variable Argument Functions                 

26.1 What You Should See

26.2 How To Break It

26.3ExtraCredit

 

27 Exercise 26: Write A First Real Program                 

27.1WhatIsdevpkg?

27.1.1WhatWeWantToMake

27.1.2 The Design

27.1.3 The Apache Portable Runtime

27.2 Project Layout

27.2.1OtherDependencies

27.3 The Makefile

27.4 The Source Files

27.4.1 The DB Functions

27.4.2 The Shell Functions

27.4.3TheCommandFunctions

27.4.4ThedevpkgMainFunction

27.5TheMid-TermExam

 

II            Data Structures And Algorithms           

28 Exercise 27: Creative And Defensive Programming                 

28.1 The Creative Programmer Mindset

28.2 The Defensive Programmer Mindset

28.3TheEightDefensiveProgrammerStrategies

28.4 Applying The Eight Strategies

28.4.1 Never Trust Input

28.4.2 Prevent Errors

28.4.3FailEarlyAndOpenly

28.4.4DocumentAssumptions

28.4.5 Prevention Over Documentation

28.4.6 Automate Everything

28.4.7SimplifyAndClarify

28.4.8QuestionAuthority

28.5 Order Is Not Important

28.6ExtraCredit

 

29 Exercise 28: Intermediate Makefiles                 

29.1TheBasicProjectStructure

29.2Makefile

29.2.1 The Header

29.2.2 The Target Build

29.2.3TheUnitTests

29.2.4TheCleaner

29.2.5TheInstall

29.2.6TheChecker

29.3 What You Should See

29.4ExtraCredit

 

30 Exercise 29: Libraries And Linking                 

30.0.1DynamicallyLoadingASharedLibrary

30.1 What You Should See

30.2 How To Break It

30.3ExtraCredit

 

31 Exercise 30: Automated Testing                 

31.1 Wiring Up The Test Framework  

 31.2ExtraCredit

 

32 Exercise 31: Debugging Code                 

32.1 Debug Printing Vs. GDB Vs. Valgrind

32.2 A Debugging Strategy

32.3UsingGDB

32.4 Process Attaching

32.5 GDB Tricks

32.6ExtraCredit

 

33 Exercise 32: Double Linked Lists                 

33.1WhatAreDataStructures

33.2 Making The Library

33.3 Double Linked Lists

33.3.1 Definition

33.3.2 Implementation

33.4 Tests

33.5 What You Should See

33.6HowToImproveIt

33.7ExtraCredit

 

34 Exercise 33: Linked List Algorithms                 

34.0.1 Bubble And Merge Sort

34.0.2 The Unit Test

34.0.3TheImplementation

34.1 What You Should See

34.2HowToImproveIt

34.3ExtraCredit

 

35 Exercise 34: Dynamic Array                 

35.1 Advantages And Disadvantages

35.2HowToImproveIt

35.3ExtraCredit

 

36 Exercise 35: Sorting And Searching                 

36.1 Radix Sort And Binary Search

36.1.1CUnions   

36.1.2TheImplementation   

36.1.3 RadixMap_find And Binary Search  

 36.1.4RadixMap_sortAndradix_sort   

36.2HowToImproveIt   

36.3ExtraCredit  

 

37 Exercise 36: Safer Strings                 

37.1 Why C Strings Were A Horrible Idea  

37.2 Using bstrlib

37.3 Learning The Library

 

38 Exercise 37: Hashmaps                 

38.0.1 The Unit Test

38.1HowToImproveIt

38.2ExtraCredit

 

39 Exercise 38: Hashmap Algorithms                 

39.1 What You Should See

39.2 How To Break It

39.3ExtraCredit

 

40 Exercise 39: String Algorithms                 

40.1 What You Should See

40.2AnalyzingTheResults

40.3ExtraCredit

 

41 Exercise 40: Binary Search Trees                 

41.1HowToImproveIt
41.2ExtraCredit

 

42 Exercise 41: Using Cachegrind And Callgrind For Performance Tuning

42.1 Running Callgrind

42.2 Callgrind Annotating Source

42.3AnalyzingMemoryAccessWithCachegrind

42.4JudoTuning

42.5UsingKCachegrind

42.6ExtraCredit

 

43 Exercise 42: Stacks and Queues                 

43.1 What You Should See

43.2HowToImproveIt

43.3ExtraCredit

 

44 Exercise 43: A Simple Statistics Engine                 

44.1 Rolling Standard Deviation And Mean

44.2 Implemention

44.3HowToUseIt

44.4ExtraCredit

 

45 Exercise 44: Ring Buffer                 

45.1 The Unit Test

 45.2 What You Should See

45.3HowToImproveIt

45.4ExtraCredit

 

46 Exercise 45: A Simple TCP/IP Client                 

46.1AugmentTheMakefile

46.2ThenetclientCode

46.3 What You Should See

46.4 How To Break It

 46.5ExtraCredit

 

47 Exercise 46: Ternary Search Tree                 

47.1 Advantages And Disadvantages

 47.2HowToImproveIt   

47.3ExtraCredit  

 

48 Exercise 47: A Fast URL Router                 

48.1 What You Should See

48.3ExtraCredit

 

49 Exercise 48: A Tiny Virtual Machine Part 1                 

49.1 What You Should See

49.2 How To Break It  

 49.3ExtraCredit

50 Exercise 48: A Tiny Virtual Machine Part 2                 

50.1 What You Should See

50.2 How To Break It 50.3ExtraCredit

 

51 Exercise 50: A Tiny Virtual Machine Part 3                 

51.1 What You Should See

51.2 How To Break It

51.3ExtraCredit

 

52 Exercise 51: A Tiny Virtual Machine Part 4                 

52.1 What You Should See

52.2 How To Break It

52.3ExtraCredit

 

53 Exercise 52: A Tiny Virtual Machine Part 5                 

53.1 What You Should See

53.2 How To Break It

53.3ExtraCredit

54 Next Steps                 

 

III            Reviewing And Critiquing Code           

55 Deconstructing "K&R C"                 

55.1 An Overall Critique Of Correctness

55.1.1AFirstDemonstrationDefect

55.1.2 Why copy() Fails

55.1.3But,That’sNotACString

55.1.4 Just Don’t Do That

55.1.5 Stylistic Issues

55.2 Chapter 1 Examples

Rewards Program

Write a Review