0

I read binary data in a file. The code is here below:

        fread (buffer, sizeof(char), 8, fid);
        int i;
        printf("buffer ");
        for (i=0; i <8; i++)
            printf("%02X ", buffer[i] & 0x00ff);
        printf("\r\n");

The file contains the herebelow data. One byte is 0x1A (substitution char). data file: When the 0x1A byte is read, all bytes read after are not updated as show here, all lines stay the same:

buffer FE 80 FA C0 00 80 00 0A
buffer 05 80 E4 C0 00 C0 00 0A
buffer 09 40 F0 C0 FD C0 00 0A
buffer 0A 40 0E 40 FA 00 00 0A
buffer F8 80 42 C0 00 C0 00 0A
buffer FF 80 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A
buffer 08 C0 2B 80 F8 80 00 0A

Why is there this problem in C? How can I solve it?

Best regards. Mich.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
Mich
  • 119
  • 1
  • 8

0 Answers0