C에서 itoa 함수를 사용하여 int를 문자열로 변환할 수 있습니다.
예
#include<iostream>
int main() {
int a = 10;
char *intStr = itoa(a);
string str = string(intStr);
cout << str;
} 출력
이것은 출력을 줄 것입니다 -
10
이는 정수를 문자열로 변환합니다. C++11에서는 같은 용도로 사용할 수 있는 새로운 메소드인 to_string이 추가되었습니다. 다음과 같이 사용할 수 있습니다 -
예시
#include<iostream>
using namespace std;
int main() {
int a = 10;
string str = to_string(a);
cout << str;
} 출력
이것은 출력을 제공합니다 -
10