I have the following .bin file
1f ac 00 78 00 3f 00 c3 00 83....
and I have to go through it using pointer arithmetic. I have to capture the first byte, which will tell me how many “words” I will process, then every two bytes will tell me the offset, where should I start reading. My problem is that I get the first byte without any problems, but now all I am trying to do is increase my pointer so that it points to ac, drops it to uint16_t, prints this value, do some procedures, and now I want him to point to 78. Here is what I have written so far:
Pre: Buffer points to a region of memory formatted as specified.
Log points to an opened text file.
Post: The target of Buffer has been parsed and report written as specified
uint8_t doStuff(uint8_t *Buffer, FILE *Log)
{
int wordsToProcess = *(Buffer);
uint16_t offset = 0;
bool firstTime = true;
for (int i = 0; i < wordsToProcess; i++)
{
if (firstTime)
{
Buffer++;
offset = *((uint16_t*)Buffer);
fprintf(Log, "Looking for %0X words, starting at %0X\n",
wordsToProcess, offset);
firstTime = false;
}
else
{
Buffer += 2;
offset = *((uint16_t*)Buffer);
}
}
}
hexdump, , 66. , Buffer, , , , , Buffer , . - , ?