[your code here] HexViewer

Biotronic via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 3 02:15:18 PDT 2017


On Thursday, 3 August 2017 at 08:47:12 UTC, Martin Tschierschke 
wrote:
> Can you point me to the explanation of this: %(%02X %)%*s  %s  ?

https://dlang.org/phobos/std_format.html

Under "Example using array and nested array formatting:"

writefln("My items are %(%s %).", [1,2,3]);

So "%( %)" is an array format specifier, with the stuff between 
the two as the element format. In the case of "%(%02X %)%*s  %s", 
that reads:

"%("    // Start array format specifier for arg 1.
"%02X " // Format each element as a 2 digit hex number followed 
by a space.
"%)"    // End array format specifier.
"%*s"   // Right justify arg 3 (""), using width specified by arg 
2.
"  %s"  // And print arg 4 using no special format.

--
   Biotronic


More information about the Digitalmars-d mailing list