Solved

ostringstream

Posted on 2003-12-07
2
201 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

628 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