[C++] String Split and Cin (STDIN)

1. 如何將一個 string 分開存入數值中?

string s("Somewhere down the road");
istringstream iss(s);

do
{
    std::string sub;
    iss >> sub;
    std::cout << "Substring: " << sub << std::endl;
} while (iss);

2. 如何利用 cin 批次讀取輸入資料

 while(cin) {
    getline(cin, input_line);
    cout << input_line;
}