fork(3) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. vector<int> v {1, 2, 3, 4};
  9. int x;
  10.  
  11. for (x : v)
  12. cout << x << endl;
  13.  
  14. cout << "The last one was " << x << endl;
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1
2
3
4
The last one was 0