Formatting in C++
Peter L. Peres
plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Fri Dec 26 20:40:05 UTC 2003
On Fri, 26 Dec 2003, John Wildberger wrote:
> I also tried a few other suggestins, given by by Peter Peres but also with
> negative success.
> It seems that the good old printf() is still the best to use. It just bugs me
> not being able to do it with cout.
info iostream, menu nodes:
Streams->Ostream->Writing
where we find the prototype of:
ostream::form(const char *FORMAT, ...)
also:
Streams->Iostreams->Ios->Format Control
and 'Manipulators', which contains some examples. Your code would be:
cout << "Yada: 0x" << setw(2) << hex << buf[i] << nl;
and f_unit8 could be:
#define f_uint8 setw(2) << hex
so you could:
cout << "Yada: 0x" << f_uint8 << buf[i] << nl;
Peter
PS: You should take a moment (or a day) and index your system. This info
and much more is on your machine.
--
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