0

With printf we can print a formatted string to the console output.

Question: How can we get the formatted string as std::string?

John Threepwood
  • 15,073
  • 26
  • 88
  • 146

2 Answers2

0

You may use sscanf to convert it to a char* and then, use it to make a std::string.

Paul92
  • 8,449
  • 1
  • 21
  • 34
0

use sprintf instead, but it will return a char*

int sprintf ( char * str, const char * format, ... );