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?
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?
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].
uint8_t
, you need to #include <stdint.h>