C++:Conversion int en String
De Centre de Ressources Numériques - Labomedia
#include <iostream>
#include <sstream> // stringstream
using namespace std;
string intToHexString (int n) {
ostringstream oss;
oss << hex << n;
return oss.str();
}
string intToString (int n) {
ostringstream oss;
oss << n;
return oss.str();
}
int main(int argc, char *argv[]) {
cout << intToHexString(123) << endl;
cout << intToString(123) << endl;
return 0;
}