public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Moore, Mathew L" <MooreML@BATTELLE.ORG>
To: "'Jessee, Mark'" <Mark.Jessee@gdcanada.com>,
	"'gcc-help@gcc.gnu.org'" <gcc-help@gcc.gnu.org>
Cc: 'bjorn rohde jensen' <bjensen@fastmail.fm>
Subject: RE: Problems with stringstream
Date: Fri, 25 Oct 2002 10:15:00 -0000	[thread overview]
Message-ID: <2F05A390F72A0A409390E016D23E45E8042DBED5@ns-bco-mse4.im.battelle.org> (raw)

std::endl will flush the buffer (after adding a new line).  If you don't
want to add the newline then you can just flush() it:

  cout << mystr;
  cout.flush();

Do you need to add the extra strings as well, or does just the flush() work
for you?

I thought that the streams were automatically flushed when they reached the
end of their scope (at the end of your main function here).  Anybody know if
that is incorrect?

--Matt


> -----Original Message-----
> From: Jessee, Mark [mailto:Mark.Jessee@gdcanada.com]
> Sent: Friday, October 25, 2002 12:48
> To: 'Moore, Mathew L'; Jessee, Mark; 'gcc-help@gcc.gnu.org'
> Subject: RE: Problems with stringstream
> 
> 
> Matt,
> 
> Your example fails as well.  But I found if I modify it a bit 
> (see below),
> it works fine.  Still not sure why though.  Thoughts?  
> Something to do with
> flushing the stream?
> 
> #include <iostream>
> #include <sstream>
> #include <string>
> using namespace std;
> 
> int main ()
> {
>    stringstream oss;
>    string mystr;
> 
>    oss << "Sample string";
>    mystr=oss.str();
> 
>    cout << "get ready..." << endl;
>    cout << mystr;
>    cout << "all done" << endl;
> 
>    return 0;
> }
> 
> -----Original Message-----
> From: Moore, Mathew L [mailto:MooreML@BATTELLE.ORG]
> Sent: Friday, October 25, 2002 10:44 AM
> To: 'Jessee, Mark'; 'gcc-help@gcc.gnu.org'
> Subject: RE: Problems with stringstream
> 
> 
> I wonder if this problem can be narrowed down?  Does it take 
> this exact code
> listing to reproduce the problem?  Can you just print out a string?
> 
> 	string mystr("test");
> 	cout << mystr;
> 
> If your debugger produces the correct result, it would at 
> least seem that
> the stringstream portion is working correctly.  I wonder if 
> your stdout was
> remapped somewhere (is that possible?).
> 
> --Matt
> 
> 
> 
> > -----Original Message-----
> > From: Jessee, Mark [mailto:Mark.Jessee@gdcanada.com]
> > Sent: Friday, October 25, 2002 12:30
> > To: 'gcc-help@gcc.gnu.org'
> > Cc: 'John Love-Jensen'
> > Subject: RE: Problems with stringstream
> > 
> > 
> > I'm running it on Mandrake Linux.  When I run it from the 
> > command line - no
> > output.  However when I run it from the ddd debugger, it 
> > works fine!  Huh?!?
> > 
> > -----Original Message-----
> > From: John Love-Jensen [mailto:eljay@adobe.com]
> > Sent: Friday, October 25, 2002 10:22 AM
> > To: Jessee, Mark
> > Subject: Re: Problems with stringstream
> > 
> > 
> > Using GCC 3.2 on Cygwin, your example worked perfectly as one 
> > would expect.
> > 
> > Hmmm.
> > 
> > --Eljay
> > 
> 

             reply	other threads:[~2002-10-25 17:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-25 10:15 Moore, Mathew L [this message]
     [not found] <83E3831A88E65844B01DB1A73FB66F93023BBBAC@CSDNT99.cdcgy.com >
2002-10-28  3:07 ` Andrea Bocci
  -- strict thread matches above, loose matches on Subject: below --
2002-10-25  9:49 Jessee, Mark
2002-10-25  9:58 ` bjorn rohde jensen
2002-10-25  9:43 Moore, Mathew L
2002-10-25  9:31 Jessee, Mark
2002-10-25  9:11 Jessee, Mark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2F05A390F72A0A409390E016D23E45E8042DBED5@ns-bco-mse4.im.battelle.org \
    --to=mooreml@battelle.org \
    --cc=Mark.Jessee@gdcanada.com \
    --cc=bjensen@fastmail.fm \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).