Formatting in C++ (fwd)
Tim Writer
tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org
Mon Dec 29 18:37:35 UTC 2003
"Peter L. Peres" <plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org> writes:
> On Sat, 27 Dec 2003, John Wildberger wrote:
>
> > On December 27, 2003 02:38 pm, Peter L. Peres wrote:
> >
> > > Would it help if I'd say that I prefer to use form() for this ? ;-)
> > >
> > > The << overloading is supposed to make your life easier, not the other
> > > way around.
> > >
> > > Peter
> > This gets better with every turn. ( for me more and more mysterious). What
> > does form() do? How can I use it ?
>
> #include <iostream.h>
>
> cout << form( "%02X", buf[i] );
>
> This should be in libio (i.e. do -lio when linking if the compiler
> complains). Why not do info iostream and spend some time reading (consider
> that this is not a tutorial - you are reading manual pages). I hope that
> you know how hopeless it is to learn C++, or any language, from 5 email
> messages and a few manual pages.
A word of warning: IIRC, "form" is a GNU extension. For maximum portability,
format to a buffer using sprintf() and print the buffer.
By now, you should be convinced that porting the original program from C to
C++ yielded no benefits whatsoever at the cost of additional complexity,
portability problems, and clumsiness. Note, I'm not saying that's true for
every program but this particular program was not a good candidate.
--
tim writer <tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org> starnix inc.
905.771.0017 ext. 225 thornhill, ontario, canada
http://www.starnix.com professional linux services & products
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list