I'm writing some simple command-line shell code to interface with embedded hardware.
In some cases, I need to move data between the hardware and Windows data files.
Where I need to interactively edit the data in a file, I'm using an external hex editor (NEO, in this case.)
All that works fine, until I read from a file and manipulate the data in C, and then, only when encountering a <0d> <0a> sequence in the file.
Even though I (think I) am opening the file in binary mode, the file system always collapses that sequence to simple <0a>, reporting one fewer byte read.
The external hex editor sees the data as expected, writes it, etc.
unsigned char buff[MAX_PACKET];
FILE * fp;
// Creating file:
fp = fopen(fname, "wb");
// Reading file:
fp = fopen(fname, "rb");
nb = fread (buff, sizeof(unsigned char), MAX_PACKET, fp);
printf ("%02x %02x %02x %02x %02x %02x %02x %02x\n", buff, buff, buff, buff, buff, buff, buff, buff);
How do I get around this "feature"?
(I have also tried open() and read(), with no different results...)