cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Replacement for sprintf
Replacement for sprintf
Dec 8, 2015 at 12:47pm UTC
aquavillan
(39)
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.
Dec 8, 2015 at 1:00pm UTC
mutexe
(2372)
cin
http://www.cplusplus.com/doc/tutorial/basic_io/
Have a look at getline as well.
http://www.cplusplus.com/reference/istream/istream/getline/
for strings
Dec 8, 2015 at 1:03pm UTC
TheIdeasMan
(6817)
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 :+)
Dec 8, 2015 at 1:04pm UTC
JLBorges
(13770)
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.