Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 4
    I'm suprised you're not getting death threats for even mentioning sprintf. But that's what I use, so +1 :) Commented Mar 30, 2010 at 20:46
  • 1
    snprintf to avoid buffer overruns. See libslack.org/manpages/snprintf.3.html Commented Mar 30, 2010 at 20:52
  • 2
    *death threat* @John: There, now this answer is complete. Commented Mar 30, 2010 at 20:57
  • @John Dibling, Sadly snprintf isn't standard C++. It is standard C99, though, and is an extension probably all major standard library implementations out there for C++ which also handle C99. Commented Mar 30, 2010 at 21:12
  • 1
    Neither of these solutions implements any lookup. The arguments must be in the same order as the replacements. There is no equivalent to {{name}}; there's just %s. Commented Mar 31, 2010 at 0:01