Skip to Content
Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions
book

Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions

by Herb Sutter
August 2004
Intermediate to advanced
352 pages
7h 38m
English
Addison-Wesley Professional
Content preview from Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions

Chapter 2. The String Formatters of Manor Farm, Part 1: sprintf

Difficulty: 3

In this Item and the next, an Orwellian look at the mysteries of sprintf and why the alternatives are always (yes, always) better.

Solution

 

“All animals are equal, but some animals are more equal than others.”

 
 --George Orwell, Animal Farm
  1. What is sprintf? Name as many standard alternatives to sprintf as you can.

Consider the following C code that uses sprintf to convert an integer value to a human-readable string representation, perhaps for output on a report or in a GUI window:

// Example 2-1: Stringizing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

Herb Sutter
Navigating C++ and Object-Oriented Design

Navigating C++ and Object-Oriented Design

Paul Anderson, Gail Anderson

Publisher Resources

ISBN: 0201760428Purchase book