Skip to main content
3 of 3
Most "correct"/recent answer first
bobobobo
  • 67.9k
  • 67
  • 272
  • 375

In C++11 you can use std::to_string:

#include <string> std::string s = std::to_string(5); 

If you're working with prior to C++11, you could use C++ streams:

#include <sstream> int i = 5; std::string s; std::stringstream out; out << i; s = out.str(); 

Taken from http://notfaq.wordpress.com/2006/08/30/c-convert-int-to-string/

spoulson
  • 21.7k
  • 17
  • 79
  • 103