Search code examples
c++stringint

Converting an int to std::string


What is the shortest way, preferably inline-able, to convert an int to a string? Answers using stl and boost will be welcomed.


Solution

  • You can use std::to_string in C++11

    int i = 3;
    std::string str = std::to_string(i);