Reading file as binary

bearophile bearophileHUGS at lycos.com
Wed May 29 16:11:40 PDT 2013


Ali Çehreli:

>     writefln("0x%(%x%)", a);

But usually I prefer to show all the zero nibbles:

void main() {
     import std.stdio;
     ubyte[] a = [10, 16, 32, 123];
     writefln("0x%(%02x%)", a); // Output: 0xa10207b
     static assert(is(typeof(a[0]) == ubyte), "Only ubyte[]");
     writefln("0x%(%x%)", a);   // Output: 0x0a10207b
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list