The error is here:
BYTEINBITS buffer[512];
fread( &buffer, 512 * sizeof(char), 1, input);
buffer
is an array and therefore already a pointer but you are passing the address of that pointer to
fread
(you are passing a pointer to a pointer instead of a pointer).
A working version should look like:
uint8_t buffer[512];
fread(buffer, sizeof(buffer), 1, input);
Note that I have also removed the useless
typedef
for
uint8_t
(it makes the code less readable), the fixed buffer size of 512 and the
sizeof(char)
(which might not always the same as
sizeof(uint8_t)
). Just use
sizeof(buffer)
which expands to the array size in bytes.