Replacement for sprintf

Hello,

I am changing my way of writing code from pure C to C++. For format functions like printf, the replacement is cout. But what are the replacements for sprintf, wsprintf, and so on?

Thanks.
Hi,

One can do a lot with std::cin, std::cout, their manipulators (#include <iomanip> ) , std::string, and std::stringstream

Have a look at the documentation for these, and the algorithms and functions that go with them.

Regards :+)
See:
http://www.drdobbs.com/sutters-mill-the-string-formatters-of-ma/184401458 (slightly dated)

std::to_string() http://en.cppreference.com/w/cpp/string/basic_string/to_string
std::stoi() http://en.cppreference.com/w/cpp/string/basic_string/stol

And friends:
std::to_wstring, std::stol, std::stoll, std::stoul, std::stoull, std::stof, std::stod, std::stold

May be of interest: http://www.boost.org/doc/libs/1_59_0/libs/format/
Topic archived. No new replies allowed.