Skip to content
Search

Std::to string

lastmod 2015-05-20created 2015-05-201 edits

Returns a string with the representation of val.

Prototype

  • string to_string (int val);
  • string to_string (long val);
  • string to_string (long long val);
  • string to_string (unsigned val);
  • string to_string (unsigned long val);
  • string to_string (unsigned long long val);
  • string to_string (float val);
  • string to_string (double val);
  • string to_string (long double val);

stringstream

If the functions above are not available, use the following.

#include <string>
#include <sstream>
// ...
std::stringstream buffer;
buffer << label;
std::string str = buffer.str();

Favorite site