public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* <strstream> vs <sstream>
@ 2002-08-31  3:50 Igor Markov
  2002-08-31  4:13 ` Paolo Carlini
  0 siblings, 1 reply; 5+ messages in thread
From: Igor Markov @ 2002-08-31  3:50 UTC (permalink / raw)
  To: gcc

 
   g++ 3.1.1 and 3.2 ( which I am using on Debian Linux) complain about 
#include <strstream>
   and I am having trouble with the suggested replacement
#include <sstream>
   
   
   Here's a piece of code that compiles and runs:
#include <strstream>
int main() { char buf[10]; std::ostrstream s(buf,10); }

   I changed <stsstream> to <sstream>, but the code ceased to compile.
   Several straightforward things have been tried but didn't help.
   Therefore, I'd appreciate if someone gave me an equivalent of that
   two-line code, such that the first line is
#include <sstream>

   Pointers to relevant online material would be appreciated
   (as well as instructions for resolving similar situations
    using online manuals).
 
   thanks,
                                                 Igor
-- 
   Igor Markov         (734) 936-7829       EECS 2211
   http://www.eecs.umich.edu/~imarkov

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: <strstream> vs <sstream>
  2002-08-31  3:50 <strstream> vs <sstream> Igor Markov
@ 2002-08-31  4:13 ` Paolo Carlini
  2002-08-31 12:55   ` Igor Markov
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Carlini @ 2002-08-31  4:13 UTC (permalink / raw)
  To: imarkov; +Cc: gcc

Igor Markov wrote:

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: <strstream> vs <sstream>
  2002-08-31  4:13 ` Paolo Carlini
@ 2002-08-31 12:55   ` Igor Markov
  2002-08-31 13:06     ` Phil Edwards
  2002-08-31 16:36     ` Paolo Carlini
  0 siblings, 2 replies; 5+ messages in thread
From: Igor Markov @ 2002-08-31 12:55 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: imarkov, gcc, gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]

   Paolo,

    thanks for the equivalent code,
    but it does not seem to compile either

/n/gagarin/z/imarkov/devel/ g++ testS.cxx
testS.cxx: In function `int main()':
testS.cxx:5: `ostrstream' undeclared in namespace `std'
testS.cxx:5: parse error before `(' token
/n/gagarin/z/imarkov/devel/ g++ --version
g++ (GCC) 3.2 20020809 (Debian prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

/n/gagarin/z/imarkov/devel/ cat testS.cxx

#include <sstream>

//int main() { char buf[10]; std::osstream s(buf,10); }
  int main() { std::string buf; std::ostrstream s(buf); }
/n/gagarin/z/imarkov/devel/

                                                    Igor

Quoting Paolo Carlini <pcarlini@unitus.it>:
> Igor Markov wrote:
> 
> >   g++ 3.1.1 and 3.2 ( which I am using on Debian Linux) complain about 
> >#include <strstream>
> >   and I am having trouble with the suggested replacement
> >#include <sstream>
> >
> The <sstream> equivalent is, roughly:
> 
> #include <sstream>
> int main() { std::string buf; std::ostrstream s(buf); }
> 
> I suggest perusing §13.11 of Josuttis (ISBN: 0201379260).
> 
> Ciao, Paolo.
> 
> P.S. Strictly speaking, this list is "... for general development
> discussions...": gcc-help is more appropriate for this kind of questions.
> 
> 
> 


-- 
   Igor Markov         (734) 936-7829       EECS 2211
   http://www.eecs.umich.edu/~imarkov

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: <strstream> vs <sstream>
  2002-08-31 12:55   ` Igor Markov
@ 2002-08-31 13:06     ` Phil Edwards
  2002-08-31 16:36     ` Paolo Carlini
  1 sibling, 0 replies; 5+ messages in thread
From: Phil Edwards @ 2002-08-31 13:06 UTC (permalink / raw)
  To: imarkov; +Cc: Paolo Carlini, gcc, gcc-help

On Sat, Aug 31, 2002 at 03:00:37PM -0400, Igor Markov wrote:
>     thanks for the equivalent code,
>     but it does not seem to compile either
> 
> /n/gagarin/z/imarkov/devel/ g++ testS.cxx
> testS.cxx: In function `int main()':
> testS.cxx:5: `ostrstream' undeclared in namespace `std'
> testS.cxx:5: parse error before `(' token
> /n/gagarin/z/imarkov/devel/ g++ --version
> g++ (GCC) 3.2 20020809 (Debian prerelease)
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> /n/gagarin/z/imarkov/devel/ cat testS.cxx
> 
> #include <sstream>
> 
> //int main() { char buf[10]; std::osstream s(buf,10); }
>   int main() { std::string buf; std::ostrstream s(buf); }

-  *strstream classes are declared in <strstream>
-  *stringstream classes are declared in <sstream>
-  If you want to use both classes you must include both headers
-  *strstream classes are deprecated, stop using them and move to *stringstream

As Paolo said, a good book would be the best help here.


Phil

-- 
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
                                                 - Edsger Dijkstra, 1930-2002

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: <strstream> vs <sstream>
  2002-08-31 12:55   ` Igor Markov
  2002-08-31 13:06     ` Phil Edwards
@ 2002-08-31 16:36     ` Paolo Carlini
  1 sibling, 0 replies; 5+ messages in thread
From: Paolo Carlini @ 2002-08-31 16:36 UTC (permalink / raw)
  To: imarkov; +Cc: gcc

Igor Markov wrote:

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-08-31 16:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-31  3:50 <strstream> vs <sstream> Igor Markov
2002-08-31  4:13 ` Paolo Carlini
2002-08-31 12:55   ` Igor Markov
2002-08-31 13:06     ` Phil Edwards
2002-08-31 16:36     ` Paolo Carlini

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).