I just finished my Recover.c from pset4 and it's working perfectly, already checked with check50 and it's okay. After submitting it I checked staffs postmortem and found some differences that I would like to understand.
- Declaration of buffer: I used an array of bytes and in the postmortem an unsigned char buffer is used and it's commented that it must be done this way "otherwise the comparisons with 0xff and the like won't work!" I don't understand why.
My solution:
BYTE buffer[512];
Staff's solution:
unsigned char buffer[BLOCK_SIZE];
- Condition on while loop: my condition is that fread must return 1 element because I'm reading 1 element of size 512, so fread must return 1 element. In the staff solution, the condition checks that fread bust return == BLOCK_SIZE, which is 512. Why?
My solution:
while ( (fread(&buffer, sizeof(buffer), 1, file)) == 1 )
Staff's solution:
while (fread(buffer, 1, BLOCK_SIZE, raw_file) == BLOCK_SIZE)
Thanks in advance for the help!