I assume you want to read an entire line, and parse that as input. So, first grab the line:
std::string input;
std::getline(std::cin, input);
Now put that in a stringstream
:
std::stringstream stream(input);
and parse
while(1) {
int n;
stream >> n;
if(!stream)
break;
std::cout << "Found integer: " << n << "
";
}
Remember to include
#include <string>
#include <sstream>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…