PDA

Click to See Complete Forum and Search --> : String()


Technocrat
Dec 6th, 2000, 05:09 PM
Is there a away to turn a long to a string?

example:

long a, b, c;
CString strTemp;

a = 1;
b = 2;
c = a + b;
strTemp = c; (Heres the problem. This would just give me the coresponding ASCII char)

AfxMessageBox("1 + 1 =" + strTemp,NULL,NULL);

Any help?
Thanks

HarryW
Dec 6th, 2000, 05:34 PM
Assuming you've got <stdlib.h> included, this will do it I think:

_ltoa(c, &strTemp, 10);

Not sure if it will work with CString, here's the prototype for it anyway:

char *_ltoa( long value, char *string, int radix );


Parameters

value
Number to be converted

string
String result

radix
Base of value

Technocrat
Dec 6th, 2000, 05:36 PM
I got that honestly about 5 seconds before my email dinged for new mail. I got it to work, thanks for your quick response though.

HarryW
Dec 6th, 2000, 05:41 PM
Oh, no problem =]