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,593
  • 27
  • 93
  • 149

2 Answers2

0

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

Paul92
  • 8,827
  • 1
  • 23
  • 37
0

use sprintf instead, but it will return a char*

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