C++: Conversion int en String

#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;
}
  • c_conversion_int_en_string.txt
  • Dernière modification: 2018/03/23 14:01
  • par serge