O'Reilly logo

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

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. The String Formatters of Manor Farm, Part 2: Standard (or Blindingly Elegant) Alternatives

Difficulty: 6

Our Orwellian look at the mysteries of sprintf concludes with a comparative analysis of snprintf, std::stringstream, std::strstream, and the nonstandard but blindingly elegant boost::lexical_cast.

Solution

Alternative #1: snprintf

  1. For each of the following alternatives to sprintf, compare and contrast its strengths and weaknesses, using the analysis and example code from Item 2:

    1. snprintf

Of the other choices, sprintf

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required