I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense? 4 2655
On May 28, 8:30 pm, clb <c...@earthlink .netwrote:
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
You can start with the Apapche C++ Standard Library online
documentation,
the chapter on string streams in the User's Guide: http://incubator.apache.org/stdcxx/doc/stdlibug/31.html
On 29 Maj, 04:30, clb <c...@earthlink .netwrote:
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
You have to put the new content into the stringstream, depending on
your needs it might be as simple as to use the << operator to output
the string to the stringstream. Notice that the string you specified
in the ctor is not used as buffer for the stringstream, only
initialization. Check this site out for more information: http://www.cplusplus.com/reference/i...ingstream.html
--
Erik Wikström
clb <cl***@earthlin k.netwrote in message
news:46******** *******@earthli nk.net...
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
First, use 'MySs.clear();' to reset any 'fail flags' on the stream.
Then you can empty the stream by doing:
MySs.str("");
.... or, re-use it:
MySs.str("Hello world!");
Actually, you don't 'suck all the data out'. Try an experiment; set your
istringstream, 'suck all the data out', then try:
MySs.clear();
MySs.seekg(0); // assumes an std::[i]stringstream
..... then try 'reading' it again.
What happens?
[ correctios, as always, are welcome. ]
--
Bob R
POVrookie
Erik Wikström wrote in message...
/* """
On 29 Maj, 04:30, clb <c...@earthlink .netwrote:
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
You have to put the new content into the stringstream, depending on
your needs it might be as simple as to use the << operator to output
the string to the stringstream. Notice that the string you specified
in the ctor is not used as buffer for the stringstream, only
initialization. Check this site out for more information: http://www.cplusplus.com/reference/i...ingstream.html
- - Erik Wikström
""" */
Hi Erik,
<cough><choke a '<<' on an std::istringstr eam'? <G>
(the OP mentioned 'istringstream' , so thought I'd poke a little fun.)
Actually, I'm only (re)posting to mention to the OP that Dinkumware has some
documentation too. [ I forgot to put that in my other post]
--
Bob R
POVrookie This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Woodster |
last post by:
I am using std::stringstream to format a string. How can I clear the
stringstream variable I am using to "re use" the same variable?
Eg:
Using std::string
std::string buffer;
buffer = "value1" + " : " + "value2";
|
by: Mike Chirico |
last post by:
Sorry about the newbie question. What's the best way to convert
numbers to strings in C++. The following works, but is it better than
using the sprintf() "old C" way of converting?
#include <iostream>
#include <string>
#include <sstream>
#include <list>
|
by: KidLogik |
last post by:
Hello!
I am using std::stringstream && std::string to parse a text file ->
std::ifstream in;
std::string s;
std::streamstring ss;
int n;
I grab each line like so -> std::getline(in,s);
|
by: cherico |
last post by:
I'd like to read stings from cin and put them
in stringstream.
I use a string object as an intermediate "container"
to store data from cin and then put them in stringstream.
stringstream ss ;
string str ;
cin >> str ;
ss << str ;
|
by: David Olsson |
last post by:
Hello!
I have a little problem with one of the get methods of the
stringstream class. Consider the code:
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
| |
by: christopher diggins |
last post by:
The following program doesn't work in gcc 3.3.3:
#include <cstdlib>
#include <iostream>
#include <sstream>
using namespace std;
void FuBar(const stringstream& s) {
cout << s.str() << endl;
|
by: martinezfive |
last post by:
Hi,
I feel no doubt some documentation contains my answer, so bare with
me. Given the following:
#inclde <stdio.h>
#include <sstream>
void f()
{
std::stringstream a("Hello World!\n");
|
by: Gary Wessle |
last post by:
Hi
how can I clear a stringstream?
ss.clear();
or
ss.flush();
thanks
|
by: mthread |
last post by:
Hi,
I am using a string variable in which I do lot of appending. The
only difficulty I am facing as of now is appending a integer/float
value to this variable. Although I can accomplish this task using a
stringstream variable, it makes my life difficult as it involves 2
function call(one for adding the information to stringstream variable
and the other for copying that value in to string variable) with the
additional burden of resetting...
|
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,...
|
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...
| |
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |