Encoding an entire Byte for File Reading
This is a fragment (untested) of how you can do it:

char datafile[512];
int ch;
int index = 0;

while ((ch = file.read()) != -1) {
  datafile[i] = (char)ch;
  if (++i == 512)
    break;
}