Solved

ostringstream

Posted on 2003-12-07
2
196 Views
Last Modified: 2010-04-01
Hello, could somebody demostrate me how function ostringstream (ang generally memory streams?

thank you
0
Comment
Question by:xLeon
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
monkesdb earned 50 total points
ID: 9891827
well an outputstream has the  << operator overloaded an inputstream has the >> operator overloaded.

with file streams you are reading and writing to/from a file. but with string streams you are reading or writing strings


-------------------------
ostringstream oss();

oss << "hello";
oss << " ";
oss << "world";

string s = oss.str();

assert(s == "hello world");

--------------------------

string s;
ostringstream oss(s);

oss << "hello";
oss << " ";
oss << "world";

assert(s == "hello world");
0
 
LVL 3

Expert Comment

by:monkesdb
ID: 9891831
the first example shows you how to get the stored string, the second shows you how to associate the stream with a string.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question