Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ostringstream

Posted on 2003-12-07
2
Medium Priority
?
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
monkesdb earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

670 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