Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::sprintf

 

Never use std::sprintf [1]. For a simple conversion between data types, prefer using boost::lexical_cast [2]. For simple formatting with need for templatability, one might want to use std::stringstream or std::strstream [2]. For complex formatting and no need for templatability, one might want to use std::snprintf [2].

 

 

 

 

 

References

 

  1. Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 3 guideline: 'Never use sprintf'.
  2. Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 3 table 3-2: Guideline summary.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict