Originally posted by namgor: string B = (string) A;
No, you see A is not a string, it's long.
Anywhoo, i think i found a function taht sorta kinda does that, it works like this (for future reference)
int radix = 10; // base (2,8,10,16, whatever)
char buffer[33];// temp buffer
char *strptr;// pointer to an aray of characters (string)
strptr = ltoa(12345678,buffer,radix);
printf("The value is: %s\n",strptr);
------------------
There are no stupid questions, there are stupid answers.
[This message has been edited by IL96 (edited July 16, 2001).]
There are no stupid questions, there are stupid answers.
int main()
{
int i = 123;
std::stringstream buf;
buf<<i;
std::string thestring = buf.str();
std::cout << thestring.c_str();
return 0;
}
sorry my first version of code was incorrect because std::string does not provide any overloaded operators for conversion so what you need is a string stream
and dynamic_cast is for casting between hirarchily related objects (eg. base to derived) using runtime type identification so it has no use here
BTW the includes dont have .h in them because that is the C++ style and puts the classes in the namespace "std" hence the use of std::
[This message has been edited by dighn (edited July 17, 2001).]
I'm just an amateur C programmer. So I only know the basics of casts and such. I don't really use them much except once in a while when I have to for functions I write or what not.
Thanks again, learn something new everyday.
[This message has been edited by biosx (edited July 17, 2001).]
Bookmarks