|
|
Darren New <dne### [at] sanrrcom> wrote:
> I think C# actually came up with quite a sweet compromise. (Well, maybe not
> came up with, maybe "stole", but it's pretty good anyway.) You put in
> something like
> output.write("blah {0:x} blah {2:y} blah {1:0,000.00}", a, b, c);
In C++ you could use the boost format library, which allows you to do
things like this:
std::cout << boost::format("writing %1%, x=%2% : %3%-th try")
% "toto" % 40.23 % 50;
(OTOH I'm guessing this is less efficient than the direct approach.)
> Last time I had to do something like that, I used
> typedef int MySpecialInt;
> #define MySpecialIntFmt "%i"
> and then
> printf("Here are " MySpecialIntFmt " integers", i);
Which is inconvenient if you need to use some format specifiers (such
as printing at least 5 digits, with leading zeros).
--
- Warp
Post a reply to this message
|
|