[C++] string to int
stoi, stof, stol, stod 함수에 대해서 (string to int)
▼ C++11 부터 아래 함수들을 사용할 수 있습니다.
stoi = string to int
stof = string to float
stol = string to long int
stod = string to double
아래처럼 다른것들도 있지만 많이 사용하진 않아서요.
위에 4개(stoi, stof, stol, stod)에 대해서만 다루겠습니다.
stoul = string to unsigned int
stoll = string to long long
stoull = string to unsigned long long
stold = string to long double
2. C++ stoi, stof, stol, stod 함수 원형과 매개변수가 뜻하는 것
▼ 함수 원형
1) 정수형
int stoi(const string& str, size_t* idx = 0, int base = 10)
long stol(const string& str, size_t* idx = 0, int base = 10)
2) 실수형
float stof(const string& str, size_t* idx = 0)
double stod(const string& str, size_t* idx = 0)
[C++] stoi, stof, stol, stod 함수에 대해서 (string to int)
안녕하세요. BlockDMask 입니다. 지난시간에는 C/C++에 기존에 존재하던 atoi, atof, atol등 char* 타입의 문자열을 정수로, 실수로 (=숫자로) 변경하는 함수에 대해서 살펴 보았습니다. 오늘은! C++11에서 부
blockdmask.tistory.com