Topic: STL strings and formatting


Author: Nick Brook <ncb@adaptivebroadband.com>
Date: 1999/05/22
Raw View
I'd like to use STL strings for everything, but I can't find a way of
producing formatted strings without resorting to sprintf and a char
buffer (which rather defeats the object of encapsolating the memory
management functionality). Surely there must be an equivalent to the MFC
CString.Format() method?

Cheers,
        Nick Brook

        Adaptive Broadband Ltd.
        Cambridge
        UK
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: sbnaran@dirac.ceg.uiuc.edu (Siemel Naran)
Date: 1999/05/22
Raw View
On 22 May 99 18:47:30 GMT, Nick Brook <ncb@adaptivebroadband.com> wrote:

>I'd like to use STL strings for everything, but I can't find a way of
>producing formatted strings without resorting to sprintf and a char
>buffer (which rather defeats the object of encapsolating the memory
>management functionality). Surely there must be an equivalent to the MFC
>CString.Format() method?

Yes,
   #include <sstream> // ostringstream and istringstream

--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.edu)
----------------------------------
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]