출처 : https://learn.microsoft.com/ko-kr/cpp/standard-library/string-functions?view=msvc-170
#include <string>
in_stream 에서 delimiter를 기준으로 str에 한줄씩 추출함
공백 문자 포함 입력에서 많이 사용
default delimiter used
template <class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>& in_stream,
basic_string<CharType, Traits, Allocator>& str);
template <class Allocator, class Traits, class Allocator>
basic_istream<Allocator, Traits>& getline(
basic_istream<Allocator, Traits>&& in_stream,
basic_string<Allocator, Traits, Allocator>& str);
template <class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>& in_stream,
basic_string<CharType, Traits, Allocator>& str,
CharType delimiter);
template <class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>&& in_stream,
basic_string<CharType, Traits, Allocator>& str,
const CharType delimiter);
int main(){
string str;
getline(cin,str);
cout<<str<<'\n';
while(getline(cin,str,',')){
cout<<str<<'\n';
}
}
string to_string(int value);
string to_string(unsigned int value);
string to_string(long value);
string to_string(unsigned long value);
string to_string(long long value);
string to_string(unsigned long long value);
string to_string(float value);
string to_string(double value);
string to_string(long double value);
-Example
int main(){
int v=INT32_MAX;
unsigned int uv=INT32_MAX;
long lv=INT32_MAX;
unsigned long ulv=INT32_MAX;
long long llv=INT64_MAX;
unsigned long long ullv=INT64_MAX;
float fv=0.000001;
double dv=0.000001;
long double ldv = 0.000001;
}
int stoi(
const string& str,
size_t* idx = 0,
int base = 10);
int stoi(
const wstring& str,
size_t* idx = 0,
int base = 10);
long stol(
const string& str,
size_t* idx = 0,
int base = 10);
long stol(
const wstring& str,
size_t* idx = 0,
int base = 10);
unsigned long stoul(
const string& str,
size_t* idx = 0,
int base = 10);
unsigned long stoul(
const wstring& str,
size_t* idx = 0,
int base = 10);
long long stoll(
const string& str,
size_t* idx = 0,
int base = 10);
long long stoll(
const wstring& str,
size_t* idx = 0,
int base = 10);
unsigned long long stoull(
const string& str,
size_t* idx = 0,
int base = 10);
unsigned long long stoull(
const wstring& str,
size_t* idx = 0,
int base = 10);
float stof(
const string& str,
size_t* idx = 0);
float stof(
const wstring& str,
size_t* idx = 0);
double stod(
const string& str,
size_t* idx = 0);
double stod(
const wstring& str,
size_t* idx = 0
;
double stold(
const string& str,
size_t* idx = 0);
double stold(
const wstring& str,
size_t* idx = 0);
int main(){
string S_BASE_2="110";
string S_BASE_10="6";
if(stoi(S_BASE_2,0,2)==stoi(S_BASE_10))
cout<<"true"<<'\n';
cout << stol("123456789") <<'\n';
cout << stoul("12345689") <<'\n';
cout << stoll("123456789123456789") <<'\n';
cout << stoull("123456789123456789") <<'\n';
cout << stof("3.14") <<'\n';
cout << stod("3.141592653589") <<'\n';
cout << stold("3.141592653589") <<'\n';
}