fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <vector>
  4.  
  5. int main() {
  6. // populate vector
  7. std::vector<int> v;
  8. for (int n; std::cin >> n; )
  9. v.push_back(n);
  10.  
  11. // print vector
  12. for (int n : v )
  13. std::cout << n << '\n';
  14.  
  15. return !std::cin.eof(); // success on eof
  16. }
  17.  
Success #stdin #stdout 0s 16056KB
stdin
1 2 3 4
stdout
1
2
3
4