You have a slight misunderstanding for the cout concept. cout is a stream, and the operator <is defined for any stream. So you just need another stream that writes to a string to output your data. You can use a standard stream, for example std :: ostringstream, or define your own.
So your analogy is not very accurate, since cout is not a function of printf and sprintf
source share