[C++] ostrstream vs. sprintf

From: Karl B Buchner (zerker@juno.com)
Date: 02/05/02


I was looking through some C++ documentation, and I noticed the
ostrstream class (heretofor unbeknownst to me).  Up to now I have
been using the standard Circle char buf[] and sprintf functions to
do most of my string writing, and what I'm wondering now is
whether ostrstream (or perhaps some still unbeknownst function or
class) would be better to use than sprintf.  From a look at the
description ostrstream has the following advantages over sprintf:
        -dynamic size
        -no need for messy %-5ld type stuff
one disadvantage that I noticed was cases where you want to
set the size of the parameter (i.e. %20s).  Of course sprintf
could be used only in the cases where this is needed.

<flame protection>
Yes, my MUD is C++, and yes, I know ostrstream is not
compatable with stock Circle.
</flame protection>

The penguins have my typewriter,

^Blaize^

p.s.  heretofor and unbeknownst are among the top 10 best
words in the english language.  Up there with yon, hither, and
yea.  I probably used them incorrectly too, despite my 95%
rating in SKILL_ARCHAIC.
________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
http://dl.www.juno.com/get/web/.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT