473,715 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem facing while using ostream_iterato r

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_it erator<int>(cou t, " "));
// Output: 0 1 2
return 0;
}

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

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

Nov 13 '06 #1
2 1967

alzf...@yahoo.c om 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_it erator<int>(cou t, " "));
// Output: 0 1 2
return 0;
}

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

I have made the search in /usr/include for ostream_iterato r but i
have'nt find it.
stream.cc:38: syntax error before `>' token
Nov 13 '06 #2
al*****@yahoo.c om wrote:
>
I have made the search in /usr/include for ostream_iterato r but i
have'nt find it.
Check the documentation of ostream_iterato r. 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
2038
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
4495
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> #include <ext/numeric> #include <algorithm> #include <ext/algorithm>
2
2905
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 I am facing, giving a small test program to demonstrate . typedef vector<intVI; VI v; //vector of int.
7
2123
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) type as in "template <typename T>" or "template <class T>" 2) non-type as in "template <int N>" 3) class template as in "template <template<typenameclass C>" "
5
3656
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 define map type with my new type (structure) everything is OK. All compileres I've cheked report an error so I think it is a problem with my code. #include <algorithm> #include <cstddef>
6
5713
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 * vector<string>. Now, use istringstream to read read each line * from the vector a word at a time.
2
7280
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
2910
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
1445
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
8821
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9340
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9196
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9047
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2539
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.