#include <iostream>
#include <vector>
int main()
{
constint sentinel = -999999 ;
std::vector<int> numbers ;
std::cout << "enter integers one by one, enter " << sentinel << " to end input:\n" ;
int v ;
while( std::cin >> v && v != sentinel ) numbers.push_back(v) ;
// use numbers in the vector
}
#include <iostream>
int main()
{
std::cout << "enter integers separated by spaces on a single line\n"" an enter immediately after the last integer ends the input:\n" ;
int v ;
// http://en.cppreference.com/w/cpp/io/basic_istream/peekwhile( std::cin >> v && std::cin.peek() != '\n' ) std::cout << v << ' ' ;
std::cout << v << "\nEND\n" ;
}
#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::cout << "enter integers separated by spaces on a single line\n"" an enter ends the input:\n" ;
std::string line ;
// http://www.cplusplus.com/reference/string/string/getline/
std::getline( std::cin, line ) ; // read an entire line into the string
// http://en.cppreference.com/w/cpp/io/basic_istringstream
std::istringstream stm(line) ; // construct an input string stream to read from the string
int v ;
// read in integers, one by one, from the string stream and print them out
while( stm >> v ) std::cout << v << ' ' ;
std::cout << "\nEND\n" ;
}