What data structure do I use to store the 512B blocks in a buffer?

Thinking about an array or ints? Or am I completely off?

  • Do you try to update appliance with update50 ? Sep 6, 2014 at 15:09
  • Ah sorry if I was't clear, I was working on recover from pset5!
    – Jesse
    Sep 6, 2014 at 16:07

1 Answer 1


You definitely need to store it in an array. However, think about the size each element in that array should have. An int usually has 4 bytes. What you want is to look for jpg signatures, which are 4 bytes at the beginning of each 512 byte block potentially. In order to store these 4 individual bytes correctly, you need a buffer of a type like this:

BYTE buffer[512];

where BYTE should be defined as having exactly 8 bits, or one byte. Like this:

typedef uint8_t  BYTE; (from pset5, bmp.h)

To look for a jpg signature later, you can then easily access the first four bytes by looking at buffer[0], buffer[1], buffer[2], and buffer[3].

  • Would I have to include "bmp.h" header file since I'm accessing the typedef struct BYTE?
    – sisball8
    Apr 9, 2016 at 14:33
  • No, you can write the typedef directly into your recover.c code and create a type without needing to reference other documentation
    – Geist0504
    Mar 20, 2017 at 1:51
  • Actually, in order to call uint8_t, you need to #include <stdint.h>
    – Raoul
    Sep 15, 2019 at 13:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .