Posts: 1,439
Threads: 15
Joined: Apr 2003
That works if you want an STL string, but if you just want a standard char array, you can do something like this:
Code:
char s[20];
int x = 23;
sprintf(s, "%d", x);
Although you probably wouldn't need that big of a buffer...
Posts: 108
Threads: 40
Joined: Aug 2001
if your using C++.. I don't see why you wouldn't use STL, I mean, you can easily convert back and forth between string and char *..
char * cstr = str.c_str();
string str = string(cstr);
COUNT HACKED BY RAZVEEE
RAZVEE IS A SCRIPT KIDDIE- hacker9
Posts: 1,439
Threads: 15
Joined: Apr 2003
Oh, thanks. That's helpful, because I've been converting from string to char* using the data() method, which only returns a const char*, so I go through and copy the string data to another non-const char* until I hit a null char... Yay! Less code.