Quote:
Originally Posted by Foly
A function that converts an integer variable to a string:
Code:
string IntToStr(int Input) {
int Number = Input;
string tempstr;
tempstr = "";
while (Number > 0) {
switch (Number % 10) {
case 0: tempstr = "0" + tempstr; break;
case 1: tempstr = "1" + tempstr; break;
case 2: tempstr = "2" + tempstr; break;
case 3: tempstr = "3" + tempstr; break;
case 4: tempstr = "4" + tempstr; break;
case 5: tempstr = "5" + tempstr; break;
case 6: tempstr = "6" + tempstr; break;
case 7: tempstr = "7" + tempstr; break;
case 8: tempstr = "8" + tempstr; break;
case 9: tempstr = "9" + tempstr; break;
}
Number = Number/10;
}
if (tempstr == "")
tempstr = "0";
return tempstr;
}
|
I... don't want to play smart ass or anything, but I know a slightly shorter piece of code for that:
Code:
formatInt(value,"l");
__________________
I am an official JJ2+ programmer and this has been an official JJ2+ statement.
|