Get each value from a string via std::ifstream
问题 I am try to use an ifstream with the while loop to get each value. However, when I try it, nothing happens. Why? std::string line; std::getline(cin, line); std::ifstream stream(line); while(stream){ std::cout << stream.get(); } 回答1: You must use an istringstream , not an ifstream . 来源: https://stackoverflow.com/questions/20639889/get-each-value-from-a-string-via-stdifstream