Jeżeli nie działa std::to_string (pewnie korzystasz z C::B), to możesz użyć dwóch sposobów:
1. Sposób w stylu C++ to użycie std::ostringstream. Proponuję Ci napisanie takiej funkcji:
#include <sstream>
std::string toString(int value) {
std::ostringstream ostream;
ostream << value;
return ostream.str();
}
// Jeżeli umiesz korzystać z szablonów:
template<typename Type>
std::string toString(const Type& value) {
std::ostringstream ostream;
ostream << value;
return ostream.str();
}
2. Sposób w stylu C to użycie std::snprintf:
#include <cstdio>
std::string itoa(int value) {
char buffer[20]; // bufor o długości 20 bajtów
std::snprintf(buffer, 20, "%d", value);
return buffer; // automatyczna konwersja
}