What\'s the standard way of reading a \"line of numbers\" and store those numbers inside a vector.
file.in
12
12 9 8 17 101 2
Should I re
Here's one solution:
#include
#include
#include
#include
#include
#include
int main()
{
std::ifstream theStream("file.in");
if( ! theStream )
std::cerr << "file.in\n";
while (true)
{
std::string line;
std::getline(theStream, line);
if (line.empty())
break;
std::istringstream myStream( line );
std::istream_iterator begin(myStream), eof;
std::vector numbers(begin, eof);
// process line however you need
std::copy(numbers.begin(), numbers.end(),
std::ostream_iterator(std::cout, " "));
std::cout << '\n';
}
}