Computer/Algorithm
c++ std 이용하여 string을 unsigned int로 변환하기
Minwook Chang
2016. 10. 30. 11:19
c++ std Library가 제공하는 편리한 함수들이 있다. 이를 통해 string을 unsigned int 로 변환할 수 있다. 고정된 길이라면 더 빠르게 변환할 수 있다.
(링크 : 고정된 길이 String을 더 빠르게 변환하기)
string을 unsigned int로 변환하기
#include <iostream> // for cin, cout
#include<string> // for string, stoul, getline, stoi, etc
using namespace std;
int main(){
string str;
cout << "Enter an unsigned number : ";
getline (cin,str);
unsigned int ui = stoul(str,nullptr,0);
cout << "You entered: " << ul << endl;
return 0;
}