Connecting Tech Pros Worldwide Forums | Help | Site Map

How to use printf()-like formatting via string/iostream?

Matt
Guest
 
Posts: n/a
#1: Jul 23 '05
Hello,

Is there a means to use printf()-like formatting (eg:
http://www.mkssoftware.com/docs/man1/printf.1.asp ) using class string
and/or iostream constructs so that I need not have to define
fixed-size character buffers (like it appears that I have to do in
printf()...or maybe there's an alternative)?

-Matt
--
Remove the "downwithspammers-" text to email me.

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 23 '05

re: How to use printf()-like formatting via string/iostream?


"Matt" <matt@downwithspammers-mengland.net> wrote...[color=blue]
> Is there a means to use printf()-like formatting (eg:
> http://www.mkssoftware.com/docs/man1/printf.1.asp ) using class string
> and/or iostream constructs so that I need not have to define
> fixed-size character buffers (like it appears that I have to do in
> printf()...or maybe there's an alternative)?[/color]

I am not sure where the question comes from (have you a good book that
talks about formatted output?) but please look at "stream manipulators",
declared in <iomanip> header. All necessary manipulators are there to
make the string stream output function the same as printf-based.

V


Matthias
Guest
 
Posts: n/a
#3: Jul 23 '05

re: How to use printf()-like formatting via string/iostream?


Matt wrote:[color=blue]
> Hello,
>
> Is there a means to use printf()-like formatting (eg:
> http://www.mkssoftware.com/docs/man1/printf.1.asp ) using class string
> and/or iostream constructs so that I need not have to define
> fixed-size character buffers (like it appears that I have to do in
> printf()...or maybe there's an alternative)?
>
> -Matt
> --
> Remove the "downwithspammers-" text to email me.[/color]

If you're looking for the "%x"-formatting-style functionality of printf,
check out the boost format library
http://www.boost.org/libs/format/index.html

--
Regards,
Matthias
James Aguilar
Guest
 
Posts: n/a
#4: Jul 23 '05

re: How to use printf()-like formatting via string/iostream?



"Matthias" <nospam@digitalraid.com> wrote in message
news:culck8$640$05$1@news.t-online.com...[color=blue]
> Matt wrote:[color=green]
>> Hello,
>>
>> Is there a means to use printf()-like formatting (eg:
>> http://www.mkssoftware.com/docs/man1/printf.1.asp ) using class string
>> and/or iostream constructs so that I need not have to define
>> fixed-size character buffers (like it appears that I have to do in
>> printf()...or maybe there's an alternative)?
>>
>> -Matt
>> --
>> Remove the "downwithspammers-" text to email me.[/color]
>
> If you're looking for the "%x"-formatting-style functionality of printf,
> check out the boost format library
> http://www.boost.org/libs/format/index.html[/color]

Or you could just use printf . . .


Closed Thread