By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

problem facing while using ostream_iterator

P: n/a
The code in which i m facing the problem is:
//file stream.cc

#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;
int main ()
{
vector<intV;
string from;
V.push_back(0);
V.push_back(1);
V.push_back(2);
copy(V.begin(), V.end(), std::ostream_iterator<int>(cout, " "));
// Output: 0 1 2
return 0;
}

// compiler given error:
//stream.cc: In function `int main()':
stream.cc:38: `ostream_iterator' undeclared in namespace `std' (line
number 38 is where m calling copy() algorithm).

I have made the search in /usr/include for ostream_iterator but i
have'nt find it.
stream.cc:38: syntax error before `>' token

Nov 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

alzf...@yahoo.com wrote:
The code in which i m facing the problem is:
//file stream.cc

#include <vector>
#include <algorithm>
#include <iostream>
#include <iterator>
>
using namespace std;
int main ()
{
vector<intV;
string from;
V.push_back(0);
V.push_back(1);
V.push_back(2);
copy(V.begin(), V.end(), std::ostream_iterator<int>(cout, " "));
// Output: 0 1 2
return 0;
}

// compiler given error:
//stream.cc: In function `int main()':
stream.cc:38: `ostream_iterator' undeclared in namespace `std' (line
number 38 is where m calling copy() algorithm).

I have made the search in /usr/include for ostream_iterator but i
have'nt find it.
stream.cc:38: syntax error before `>' token
Nov 13 '06 #2

P: n/a
al*****@yahoo.com wrote:
>
I have made the search in /usr/include for ostream_iterator but i
have'nt find it.
Check the documentation of ostream_iterator. It should tell you that you
need <iterator>.

--

-- Pete
Roundhouse Consulting, Ltd. -- www.versatilecoding.com
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." For more information about this book, see
www.petebecker.com/tr1book.
Nov 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.