Reading file as binary

bearophile bearophileHUGS at lycos.com
Wed May 29 16:13:08 PDT 2013


> 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
> }

I have pasted the outputs inverted, sorry.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list