By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,261 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,261 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Matt" <ma**@downwithspammers-mengland.net> wrote...
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)?


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
Jul 23 '05 #2

P: n/a
Matt wrote:
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.


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
Jul 23 '05 #3

P: n/a

"Matthias" <no****@digitalraid.com> wrote in message
news:cu*************@news.t-online.com...
Matt wrote:
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.


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


Or you could just use printf . . .
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.