* RE: Problems with stringstream
@ 2002-10-25 9:43 Moore, Mathew L
0 siblings, 0 replies; 7+ messages in thread
From: Moore, Mathew L @ 2002-10-25 9:43 UTC (permalink / raw)
To: 'Jessee, Mark', 'gcc-help@gcc.gnu.org'
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Problems with stringstream
[not found] <83E3831A88E65844B01DB1A73FB66F93023BBBAC@CSDNT99.cdcgy.com >
@ 2002-10-28 3:07 ` Andrea Bocci
0 siblings, 0 replies; 7+ messages in thread
From: Andrea Bocci @ 2002-10-28 3:07 UTC (permalink / raw)
To: Jessee, Mark
Cc: 'Moore, Mathew L', Jessee, Mark, 'gcc-help@gcc.gnu.org'
At 10.48 25/10/2002 -0600, Jessee, Mark wrote:
>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?
I guess you're right.
Probably the standard out is not automatially flushed at the end of the
program, so you don't get the last output.
Does this...
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main ()
{
stringstream oss;
string mystr;
oss << "Sample string";
mystr=oss.str();
cout << mystr << endl; // flushes stdout
return 0;
}
...work ?
fwyzard
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Problems with stringstream
@ 2002-10-25 10:15 Moore, Mathew L
0 siblings, 0 replies; 7+ messages in thread
From: Moore, Mathew L @ 2002-10-25 10:15 UTC (permalink / raw)
To: 'Jessee, Mark', 'gcc-help@gcc.gnu.org'
Cc: 'bjorn rohde jensen'
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
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problems with stringstream
2002-10-25 9:49 Jessee, Mark
@ 2002-10-25 9:58 ` bjorn rohde jensen
0 siblings, 0 replies; 7+ messages in thread
From: bjorn rohde jensen @ 2002-10-25 9:58 UTC (permalink / raw)
To: Jessee, Mark; +Cc: 'Moore, Mathew L', 'gcc-help@gcc.gnu.org'
Hi guys,
Input and output on unix systems are buffered.
std::cerr is usually line buffered, std::cout
is line buffered, when directed to a terminal
and block buffered, when connected to a file.
In case of line buffered output, you dont see
any, unless you flush it, or write a newline
character to the stream, which causes the buffer
to be flushed.
Yours sincerely,
Bjorn
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Problems with stringstream
@ 2002-10-25 9:49 Jessee, Mark
2002-10-25 9:58 ` bjorn rohde jensen
0 siblings, 1 reply; 7+ messages in thread
From: Jessee, Mark @ 2002-10-25 9:49 UTC (permalink / raw)
To: 'Moore, Mathew L', Jessee, Mark, 'gcc-help@gcc.gnu.org'
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Problems with stringstream
@ 2002-10-25 9:31 Jessee, Mark
0 siblings, 0 replies; 7+ messages in thread
From: Jessee, Mark @ 2002-10-25 9:31 UTC (permalink / raw)
To: 'gcc-help@gcc.gnu.org'; +Cc: 'John Love-Jensen'
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Problems with stringstream
@ 2002-10-25 9:11 Jessee, Mark
0 siblings, 0 replies; 7+ messages in thread
From: Jessee, Mark @ 2002-10-25 9:11 UTC (permalink / raw)
To: 'gcc-help@gcc.gnu.org'
Hi,
I'm trying to build the following program using gcc 3.0.3. It compiles okay
but when it runs there is no output. When I compile and run on MS Visual
C++ the output is "Sample string" as expected. I did a quick check of the
FAQ for this topic but couldn't find any information. Any suggestions are
appreciated!
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main ()
{
stringstream oss;
string mystr;
oss << "Sample string";
mystr=oss.str();
cout << mystr;
return 0;
}
Thanks,
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-10-28 11:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-25 9:43 Problems with stringstream Moore, Mathew L
[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 10:15 Moore, Mathew L
2002-10-25 9:49 Jessee, Mark
2002-10-25 9:58 ` bjorn rohde jensen
2002-10-25 9:31 Jessee, Mark
2002-10-25 9:11 Jessee, Mark
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).