Exception thrown while trying to read file

Matt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 3 04:30:01 PDT 2014


I am building a PE-COFF file reader, just for education purposes, 
and I keep getting a ConvException come up, stating:

---

   Unexpected '

---

Now, I have no idea how I'm getting this. The code at that point 
looks like the following:

---

   // look for the identifier
   // this gives us the offset to the magic number
   uint offs;
   file.seek(0x3c, SEEK_SET);

   file.readf("%d", &offs); // this is the problem line

   writefln("magic number offset: %d", offs);
   file.seek(offs, SEEK_SET);

---

With the exception being raised on the writefln. I have the same 
trouble with

   writeln("magic number offset: ", offs);

and I'm not sure how to go about fixing it. About the only clue I 
can come up with, is that if I were to look at the section of 
code in the hex editor, the number at that point generates a "'", 
the offending character, when represented as a character array.

Does anyone else see whatever it is that I'm doing wrong?


More information about the Digitalmars-d-learn mailing list