C++11 ~
string to_string(int value);
string to_string(long value);
string to_string(long long value);
string to_string(unsigned value);
string to_string(unsigned long value);
string to_string(unsigned long long value);
string to_string(float value);
string to_string(double value);
string to_string(long double value);
: 정수형 데이터나 실수형 데이터를 string으로 변환하여 반환합니다.
<example>
#include <iostream>
#include <string>
using namespace std;
int main()
{
int number = 35;
if (to_string(number) == "35") cout << "The current type is string." << endl;
else cout << "The current type is not a string." << endl;
return 0;
}
결과값
