In the following structure, bytesPerSector is not aligned to the sizeof(short), so after I read the raw data into buffer, and try to extract the bytesPerSector portion, I got the wrong number. Is there a easy fix for this? I am using Visual C++ Express on a x86 processor.
Code:
struct BS_Structure {
unsigned char jumpBoot[3];
unsigned char OEMName[8];
unsigned short bytesPerSector;
unsigned char sectorPerCluster;
} ptr;
unsigned char buffer[512];
unsigned short bytesize;
ReadSDCard (buffer);
ptr = (BS_Structure*) buffer;
bytesize = ptr->bytesPerSector;
Comment