Outputting a vector into a text file
I tried using the ostream_iterator method to output my vector but it hasn't worked. Are there any other methods I can use?
case 1:
1 2 3 4 5 6 7 8 9 10
|
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
vector<int> vec;
........ //fill the vec with something
copy(vec.begin(), vec.end(), ostream_iterator<int>(cout," ")); //print vec
|
If this does not work, try the normal old way.
1 2 3 4 5 6
|
vector<int> vec;
.... //fill vec
for(int i = 0; i < vec.size(); i++)
cout<<vec.at(i)<<" ";
|
Topic archived. No new replies allowed.