Reading and converting binary file 2 bits at a time

Andrew Brown via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 27 02:00:00 PDT 2015


Hi,

I need to read a binary file, and then process it two bits at a 
time. But I'm a little stuck on the first step. So far I have:

import std.file;
import std.stdio;

void main(){
   auto f = std.file.read("binaryfile");
   auto g = cast(bool[])	f;
   writeln(g);
}

but all the values of g then are just true, could you tell me 
what I'm doing wrong? I've also looked at the bitmanip module, I 
couldn't get it to help, but is that the direction I should be 
looking?

Thanks very much

Andrew


More information about the Digitalmars-d-learn mailing list