Solved

ostringstream

Posted on 2003-12-07
2
192 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now