Instead of writing your own function to convert an integer or float to a string, just use the C++ class stringstream (in the sstream header).
In C++:
#include #include #include using namespace std;void itoa(int num, string & result){ stringstream converter; converter << num; result= converter.str();}