this is a function imade the other day. i would like to know what do you think about it, and if you have any ideas how to improve it.
btw, c-strings support is almost the same although i didnt include it.Code:#include <iostream> #include <string> std::string ITOA(long Num){ std::string result=""; long * a = new long; long unsigned b = 0; for(*a=1;reinterpret_cast<long>(Num/(*a))>0;(*a)*= 10){ b++; } *a/=10; long c = *a; while(result.length()<b){ result+=(Num/(*a))+48; Num -= int((double(Num)/(c*100))*100)*c; if(*a!=1){ *a/=10; } } delete a; return result; } long ITOA(std::string Num){ long * result = new long; *result = 0; long NumOfZeroes = Num.length(); long * Num1 = new long; for(long i=0;i<Num.length();i++){ *Num1 = long(Num.c_str()[i])-48; for(long b=0;b<NumOfZeroes;b++){ *Num1 *=10; } (*result) += *Num1; NumOfZeroes--; } return (*result)/10; }