Exception thrown while trying to read file

thedeemon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 3 06:48:39 PDT 2014


On Friday, 3 October 2014 at 11:30:02 UTC, Matt wrote:
> I am building a PE-COFF file reader
>   file.seek(0x3c, SEEK_SET);
>   file.readf("%d", &offs); // this is the problem line
> Does anyone else see whatever it is that I'm doing wrong?

readf is for reading text, it expects to see some digits. You're 
reading a binary file, not a text, so no ASCII digits are found 
in that place. Use rawRead instead of readf.


More information about the Digitalmars-d-learn mailing list