Archived

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

converting an int to a char string

This topic is 5579 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

Hey all, I''m trying to convert say 9023 to "9023" I''ve looked in all my books and can''t find it. I know that there''s a function to do this, but I don''t remember what it is.

Share this post


Link to post
Share on other sites
An example:


char g_szNumber[12];
memset(g_szNumber, 0, sizeof(g_szNumber));
sprintf(g_szNumber, "%d", 9023);


And don''t forget to #include <stdio.h> or something...

Share this post


Link to post
Share on other sites

  
#include <strstring>

#include <string>

using namespace std;

int main()
{
stringstream myStringStream;
myStringStream << 9999 << "Lalala" << 132.99f;
string myString = myStringStream.str();
cout << myString;
}


[edited by - Jonus on September 8, 2002 3:25:38 PM]

Share this post


Link to post
Share on other sites