I want to write a array containing 16bit integers as raw binary to a file and have tried with the following example:
# define __int8_t_defined
__intN_t (8, __QI__);
__intN_t (16, __HI__);
__intN_t (32, __SI__);
__intN_t (64, __DI__);
int main(int argc, char *argv[])
{
FILE * rawf;
rawf = fopen("./rawPcm","wb");
int16_t buff[] = {0,0,0};
fwrite(buff,sizeof(int16_t), sizeof(buff),rawf);
fwrite(buff,sizeof(int16_t), sizeof(buff),rawf);
fclose(rawf);
}
However, the output contains more than just zeros.
$ hexdump -v rawPcm
0000000 0000 0000 0000 85fd 0804 0001 0000 0000
0000010 0000 85fd 0804 0001
0000018
It writes 0000 0000 0000 85fd 0804 0001
for every fwrite(buff,sizeof(int16_t), sizeof(buff),rawf);
while I would expect to get only 0000 0000 0000
.
What does the additional data represent 85fd 0804 0001
and how do I prevent it from occurring?