BOJ Review/C++ Techniques
[C++] std::istringstream
achrxme
2023. 8. 20. 17:44
bool isNumber(const std::string &str){
// std::istringstream : input from string
// cf. std::cin : input from keyboard
std::istringstream iss(str);
int number;
iss >> number; // try converting string to int (extract int from string)
// if input is int, the converting should be success
return !iss.fail() && iss.eof();
}
std::cin = 사용자 입력을 키보드로 받는 용도
std::istringstream = 문자열로부터 스트림 입력을 받는 용도