It sounds like one of two things is happening:
1. You're not aligning your reads correctly (are you sure you are reading at the correct offset?)
2. You're not interpreting the data correctly (not an int? wrong endian?)
Is the data after the size field being read properly? I don't know about your assignment, so I can't make any presumptions, like, the data after size is 'size' bytes.
Reading your resource as a stream of bytes (if it's a file, view the file with some binary file viewer, or print out the stream of bytes to stdout, or use the Unix or Cygwin tool 'od') to make sure you're actually reading everything correctly up to that point.
Finally, try to step through it with a debugger.