S
subramanian100in
Consider the following piece of code:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <utility>
#include <iterator>
#include <algorithm>
int main()
{
typedef pair<int, string> is;
vector<is> v;
// store values in v
ofstream ofs("output_file_word_count");
ostream_iterator<is> osi(ofs);
copy(v.begin(), v.end(), osi); ------------------------> this line
does not compile.
return 0;
}
Is it possible to print pair<int, string> with ostream_iterator ?
For example if I had vector<string>, I am able to use
ostream_iterator.
Kindly explain.
Thanks
V.Subramanian
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <utility>
#include <iterator>
#include <algorithm>
int main()
{
typedef pair<int, string> is;
vector<is> v;
// store values in v
ofstream ofs("output_file_word_count");
ostream_iterator<is> osi(ofs);
copy(v.begin(), v.end(), osi); ------------------------> this line
does not compile.
return 0;
}
Is it possible to print pair<int, string> with ostream_iterator ?
For example if I had vector<string>, I am able to use
ostream_iterator.
Kindly explain.
Thanks
V.Subramanian