댄코 - 댄싱코딩

[C/C++ 문법] int to string, string to int 변환 본문

코딩/C++

[C/C++ 문법] int to string, string to int 변환

Jk hila 2018. 5. 29. 02:11
#include <iostream>
#include <cstring>
using namespace std;
int main(){
int a = 10;
//int to string
string str = to_string(a);

//string to int
int b = stoi(str);

cout << str << endl;
cout << a+b << endl;
}


결과 : 

10

20

Comments