PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > making stringstream empty
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
making stringstream empty

Réponse
 
LinkBack Outils de la discussion
Vieux 21/02/2008, 09h20   #1
mthread
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut making stringstream empty

Hi,
I am using a variable of type stringstream in my application. I
am adding some information in the stream. I would like to know what is
the method to make the stream empty. Thanx in advance.






  Réponse avec citation
Vieux 21/02/2008, 10h11   #2
ʱ³½Î°
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: making stringstream empty

On 2ÔÂ21ÈÕ, ÏÂÎç5ʱ20·Ö, mthread <rjk...@gmail.com> wrote:
> Hi,
> I am using a variable of type stringstream in my application. I
> am adding some information in the stream. I would like to know what is
> the method to make the stream empty. Thanx in advance.


you can use clear() method to make the stream empty.
  Réponse avec citation
Vieux 21/02/2008, 10h12   #3
kasthurirangan.balaji@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: making stringstream empty

On Feb 21, 2:20pm, mthread <rjk...@gmail.com> wrote:
> Hi,
> I am using a variable of type stringstream in my application. I
> am adding some information in the stream. I would like to know what is
> the method to make the stream empty. Thanx in advance.


use str member function.

#include <sstream>

main()
{
std::stringstream sstr;
sstr << "hello";
sstr.str("");
}

Thanks,
Balaji.
  Réponse avec citation
Vieux 21/02/2008, 12h28   #4
Richard Herring
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: making stringstream empty

In message
<ccaa3c01-7313-4ed0-8b4b-34afc582ba26@t66g2000hsf.googlegroups.com>,
=?GB2312?B?yrGzvc6w?= <shichenweixjtu@gmail.com> writes
>On 2ÔÂ21ÈÕ, ÏÂÎç5ʱ20·Ö, mthread <rjk...@gmail.com> wrote:
>> Hi,
>> I am using a variable of type stringstream in my application. I
>> am adding some information in the stream. I would like to know what is
>> the method to make the stream empty. Thanx in advance.

>
>you can use clear() method to make the stream empty.


No, you can't. clear() clears the iostate flags. str("") makes it empty.

--
Richard Herring
  Réponse avec citation
Vieux 21/02/2008, 14h25   #5
Joe Greer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: making stringstream empty

"=?GB2312?B?yrGzvc6w?=" <shichenweixjtu@gmail.com> wrote in news:ccaa3c01-
7313-4ed0-8b4b-34afc582ba26@t66g2000...oglegroups.com:

> On 2ÔÂ21ÈÕ, ÏÂÎç5ʱ20·Ö, mthread <rjk...@gmail.com> wrote:
>> Hi,
>> I am using a variable of type stringstream in my application. I
>> am adding some information in the stream. I would like to know what is
>> the method to make the stream empty. Thanx in advance.

>
> you can use clear() method to make the stream empty.


It sure sounds like that's what it should do, doesn't it? Too bad it
really only clears some flags. str("") is the way to reset the string.
  Réponse avec citation
Vieux 21/02/2008, 19h03   #6
Jeff Schwab
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: making stringstream empty

mthread wrote:
> Hi,
> I am using a variable of type stringstream in my application. I
> am adding some information in the stream. I would like to know what is
> the method to make the stream empty. Thanx in advance.


ss.str(std::string());
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h57.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13452 seconds with 14 queries