Archived

This topic is now archived and is closed to further replies.

looking for an int to string converter

This topic is 5041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I looked in the visual c++ help file and couldn''t find one, I need a function that can turn a long unsigned int into a char string.
Bloodshed Dev-C++ 4.9.8.0 DX 9.0a DX SDK 6.1 win98 #define WIN32_LEAN_AND_MEAN the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

Share this post


Link to post
Share on other sites
The C++ way to do this (sprintf is C) is to use ostringstream.


#include <sstream>

using namespace std;

int i = 10;
ostringstream oss;
string s;

oss << i;
s = oss.str();




Kami no Itte ga ore ni zettai naru!

[edited by - tangentz on February 19, 2004 7:23:53 PM]

Share this post


Link to post
Share on other sites
True, but using a lexical_cast can protect you from certain bugs. For example, about a week and a half ago, a forum poster was having trouble using a stringstream method because he was reusing the stringstream object and the eof bit was being set after extraction, causing subsequent uses of the stringstream object to fail.

Share this post


Link to post
Share on other sites