언어/C&C++ 응용

[C++] String 라이브러리

차가운오미자 2021. 6. 14. 18:05

1. int를 string으로 변환하기: to_string()함수

#include <string>

int a = 234;
string str = to_string(a);

2. string 연결하기: + 연산자

string str1 = "my";
string str2 ="apple";
str1 += str2;

cout << str1; 
// result: myapple