I am in DOS mode, so there is no IntToStr().
I have to get this int into an apstring. =/
I am in DOS mode, so there is no IntToStr().
I have to get this int into an apstring. =/
does your compiler support itoa() or _itoa() ?
if it does you can use that to get a char* string then pass that to the apstring constructor.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Here is psuedocode to convert from int to string.
While the number is > 1
modulus the number by 10, convert the result to an ANSI char (add 48 I believe), add the char to the string.
Divide the number by 10
Reverse the string
Essentially, you "trap" the ones of the number each time, and divide it by 10 each time, thus sliding down the 1s place.
Personally, why are you using apstring? apstring is one of the worst string classes you can use...but anyways, this is how to do it:
int x = 10;
apstring myString;
char *cstr = itoa(x, NULL, 10);
myString = cstr;
There you go. You must include stdlib.h to be able to use itoa(), that is all.
Yeah.. I don't know why the board doesn't just teach the STL rather than use the AP classes.
Regardless, the apstring class is a subset (and nothing more), of the STL string class, likewise for the apvector (with the possible exception of the member for finding capacity, apvector uses length() while vector uses size(), IIRC.
other possibilities as itoa() isn't standard are:-
1) sprintf()
2)stringstreams.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi