How Not to Program in C++

111 Broken Programs and 3 Working Ones, or Why Does 2+2=5986?
by Steve Oualline

April 2003, 280 pp.
ISBN: 978-1-886411-95-1

This book is currently out of stock, but the ebook is still available

Find the bugs in these broken programs and become a better programmer. Based on real-world errors, the puzzles range from easy (one wrong character) to mind twisting (errors with multiple threads). Match your wits against the author's and polish your language skills as you try to fix broken programs. Clues help along the way, and answers are provided at the back of the book.


About the Author

Steve Oualline has been a programmer for 35 years. He is the author of many bestselling computer books, including Practical C Programming and Practical C++ Programming (O'Reilly).


Table of Contents

  • Chapter 1: In the Beginning
    • Program 1: Hello World
    • Program 2: Teacher's Problem
    • Program 3: Early Morning Surprise
  • Chapter 2: Starting Out on the Wrong Foot
    • Program 4: Typical Initial Problem
    • Program 5: First Errors
    • Program 6: Gotta Have My Space
    • Program 7: The Crooked Square
    • Program 8: Mad Character
    • Program 9: No Comment
    • Program 10: The Not-So-Great Divide
    • Program 11: Two Files Is Too Many
    • Program 12: Hurry Up and Wait
    • Program 13: The Program Is a Little Iffy
    • Program 14: Shifty Programming
    • Program 15: Wordless
    • Program 16: Slow but Sure
  • Chapter 3: One Character Wonders
    • Program 17: Hello Again
    • Program 18: Classic
    • Program 19: Prime Suspect
    • Program 20: Simpler Than Expected
    • Program 21: No Comment
    • Program 22: Getting too Big for Our Parameters
    • Program 23: The Long and the Short of It
    • Program 24: Overly Simple Division
    • Program 25: Maximum Surprise
    • Program 26: Trouble Area
  • Chapter 4: Daily Grind
    • Program 27: "and" and "and and"
    • Program 28: Zero Error
    • Program 29: It's Elementary, My Dear Reader
    • Program 30: A Bit of Trouble
    • Program 31: Very Small Numbers
    • Program 32: Double Trouble
    • Program 33: Bad Characters
    • Program 34: Non-Cents
    • Program 35: So You Want to Print a Million
    • Program 36: Stacked Too High
    • Program 37: This Program Has a Point
    • Program 38: Good Value
    • Program 39: Kindergarten Arithmetic Revised
    • Program 40: Unbelievable Accuracy
    • Program 41: A Bit of Trouble
    • Program 42: A Bit More Trouble
    • Program 43: Baseless
    • Program 44: Ordering Problem
    • Program 45: Triple Surprise
    • Program 46: Nothing Goes Wrong
    • Program 47: Microsoft Backwardness
    • Program 48: File Follies
    • Program 49: It's As Easy aA Falling off a Link
    • Program 50: What Is Truth Anyway
    • Program 51: A Surplus of Pluses
    • Program 52: The Case of the Disappearing Rectangle
    • Program 53: Maximum Confusion
    • Program 54: Jumping off the Deep End
    • Program 55: Sheepish Programming
    • Program 56: The Magic Is Gone from the Program
    • Program 57: How Not to Read a File
    • Program 58: Weird Names
    • Program 59: Son of Weird Names
    • Program 60: Looking through a Dictionary Slowly
    • Program 61: Zipping Along
  • Chapter 5: Those Thrilling Programs of Yesteryear
    • Program 62: Name Game
    • Program 63: p in Your Eye
    • Program 64: Temporary Insanity
    • Program 65: Buffer to Nowhere
    • Program 66: Let's Play "Hide the Problem"
    • Program 67: Miscalculating
    • Program 68: Sum Problem
    • Program 69: Two Simple
    • Program 70: Another Miscalculating
    • Program 71: No End in Sight
  • Chapter 6: Premature Breakage
    • Program 72: Pointless
    • Program 73: Gross Error
    • Program 74: Quick Exit
    • Program 75: Double Trouble
    • Program 76: No Value
    • Program 77: Margin of Error
    • Program 78: Square Deal
    • Program 79: Area Bombing
  • Chapter 7: Classes with no Class
    • Program 80: Thanks for the Memory
    • Program 81: The Case of the Disappearing Array
    • Program 82: Wild Output
    • Program 83: Construction Project
    • Program 84: Queueing Up too Long
    • Program 85: Lack of Self-Awareness
    • Program 86: Exceptional Exception
    • Program 87: File This!
    • Program 88: Just Because I'm Paranoid, It Doesn't Mean the Program Isn't Out to Get Me
    • Program 89: It's As Easy As Rolling off a Log
    • Program 90: Stacked Wrong
    • Program 91: Name Game
    • Program 92: No Magic
    • Program 93: Speed Kills
    • Program 94: Sending the Wrong Message
    • Program 95: Pure Fun
  • Chapter 8: Expert Confusion
    • Program 96: Hello Again
    • Program 97: Debug Resistant
    • Program 98: Phantom File
  • Chapter 9: Portage to Hell
    • Program 99: Going Down to Rio
    • Program 100: Point of No Return
    • Program 101: Zipping Along
  • Chapter 10: A Few Working Programs
    • Program 102: Quick Change
    • Program 103: Nothing Special
    • Program 104: Waving the Flag
  • Chapter 11: Threaded, Embedded - Dreaded
    • Program 105: Taking Out the Trash
    • Program 106: Better Trash Collector
    • Program 107: Short Time
    • Program 108: Short Time Revisited
    • Program 109: Short Time III
    • Program 110: A Bump on the Race Track
    • Program 111: Hurry Up and Wait
    • Program 112: Flag Waving
    • Program 113: Slow Progress
(top)

Reviews

". . . a unique book that is fun to read while still providing valuable
information. If you are a C++ programmer and you'd like to hone your skill,
this is a great tool to use."
--CodeGuru.com

". . . if you are looking for some cross training with the drill sergeant
of debugging, I cannot recommend this book highly enough."
--Chris Pelsor, Flash developer

"If you have been programming in C++ for a while, this book is an excellent
addition to your bookshelf."
--DEVCHANNEL.ORG

"Experienced programmers can learn a lot from [this book] and sharpen their
knowledge, whereas beginners can get a taste of the bugs that they will
produce in the future while learning how to avoid some of them."
--IBM DEVELOPER WORKS

". . . novices and experts alike will appreciate this book as a member of
their book case, more likely under "humor" than "reference", but up there
never the less."
--LINUXLOOKUP

"Based on real-world problems, approximately 100 puzzles challenge readers
to find errors in sections of code up to 40 lines long."
--BOOK NEWS, INC.

(top)

Updates

(show updates)(top)