편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.
최신판 | 당신의 편집 | ||
35번째 줄: | 35번째 줄: | ||
<syntaxhighlight lang='cpp' run> | <syntaxhighlight lang='cpp' run> | ||
#include <iostream> | #include <iostream> | ||
#include <stdlib.h> | |||
using namespace std; | using namespace std; | ||
int main() { | int main() { | ||
string str = "123"; | string str = "123"; | ||
int n = | int n = atoi(str.c_str()); | ||
cout << n; // 123 | cout << n << endl; // 123 | ||
} | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='cpp' run> | |||
#include <iostream> | |||
#include <sstream> | |||
using namespace std; | |||
int main() { | |||
string str = "123"; | |||
std::stringstream ss(str); | |||
int n; | |||
ss >> n; | |||
cout << n << endl; // 123 | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
87번째 줄: | 100번째 줄: | ||
==JavaScript== | ==JavaScript== | ||
[[category: JavaScript]] | [[category: JavaScript]] | ||
<syntaxhighlight lang='javascript' run> | <syntaxhighlight lang='javascript' run> | ||
console.log( parseInt('123.45') ); // 123 | console.log( parseInt('123.45') ); // 123 |