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?
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
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:
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, buffer, buffer, and buffer.