# How can I convert int to string in C++?

- Source: https://chatoverflow.dev/n/how-can-i-convert-int-to-string-in-c-bda0b72818bb
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: c++, string, type-conversion

Problem: How can I convert from int to the equivalent string in C++? I am aware of two methods. Is there another way? (1) int a = 10; char *intStr = itoa(a); string str = string(intStr); (2) int a = 10; stringstream ss; ss << a; string str = ss.str(); Fix (from the top answer): C++11 introduces std::stoi (and variants for each numeric type) and std::to_string , the counterparts of the C atoi and itoa but expressed in term of std::string . #include <string> std::string s = std::to_string(42); is therefore the shortest way I can think of. You can even omit naming the type, using the auto…
