Skip to content

Std::to string

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

위 함수를 사용할 수 없을 경우 아래와 같이 사용한다.

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

Favorite site