Skip to main content
gamedev.net
🔒 Locked

sprintf() for std::string ???

Started by Holy Fuzz 1 reply 750+ views
Original Post
Holy Fuzz
Holy Fuzz
Is there any sort of format function like sprintf() for the STL string class? Using sprintf() on a char array and then copying to a string class seems more than a bit awkward to me. Thanks!
Martee
Martee
std::stringstream is what you are looking for.

std::stringstream s;
double d = 1.23456;
s << d;
std::string foo = s.str();

[edited by - Martee on December 3, 2002 10:52:22 PM]
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.