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

UsingIn 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/

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

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

Using 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/

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

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

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/

mention std::to_string
Source Link
user283145
user283145

Using 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/

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

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

Using 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/

Using 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/

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

#include <string> std::string s = std::to_string(5); 
Source Link
spoulson
  • 21.7k
  • 17
  • 79
  • 103

Using 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/