473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

problem facing while using ostream_iterator

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
2 1939

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Mantoulidis | last post by:
Hello all... I get an error message for the following program by the compiler: #include <iostream> #include <string> using namespace std; ostream_iterator<string> oo(cout);
4
by: fightwater | last post by:
i wrote a program which uses the stl compose1 functor but the compiler seems cannot find it here is the code ////////////////////////////////////////// #include <vector> #include <numeric>...
2
by: toton | last post by:
Hi, I am trying to use boost::range with one of my own container class, and having some problem. I am missing some usage of range. Can anyone suggest a proper way for it ? To show the problem...
7
by: StephQ | last post by:
First of all: distinction of keywords typename and class in template arguments. Accoarding to a post in a well known moderated group: "There are three possibilities for template arguments: 1)...
5
by: krzysztof.konopko | last post by:
I cannot compile the code which defines a std::map type consisting of built in types and operator<< overload for std::map::value_type. See the code below - I attach a full example. Note: if I...
6
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a *...
2
by: subramanian100in | last post by:
Consider the following piece of code: #include <iostream> #include <fstream> #include <vector> #include <string> #include <utility> #include <iterator> #include <algorithm> int main()
5
by: Jun | last post by:
Hello, I've code like : =========================================== class A{ public : // create print content friend std::ostream& operator<< (std::ostream& os, const A& a);
2
by: 032386 | last post by:
#include <iostream> #include <vector> #include <string> #include <iterator> #include <algorithm> #include <functional> using namespace std; void reverse(string& s)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.