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.

Required fields*

3
  • 30
    Problem of this answer is, that it "Prints" string and int, this does not append it and in c++ you might want to output the value into different stream than "cout", which is not possible with printf. Commented Apr 19, 2013 at 8:31
  • 7
    @Kyborek -- I answered the question in the same terms it was asked. If you really want to append rather than print, then there is also a set of standard library of functions to do that. See for example sprintf and its safe variants (msdn.microsoft.com/en-us/library/vstudio/ybk95axf.aspx). Commented Apr 24, 2013 at 15:29
  • 5
    Following on Eric's comment: char cstr[10];sprintf(cstr,"Player %d",i); or char *cstr;asprintf(cstr,"Player %d",i); Commented Dec 26, 2013 at 17:33