trivial_example: open raw pcm files in binary mode.

The simple codec round-trip example file in the doc directory
opens an input and output pcm file. It was working fine on
POSIX systems, but not on Windows, which treats text files
differently.

This is confusing in a example, so it's better to add an
explicit binary flag to the fopen() calls. This does nothing
on unix-like systems, but should make the example work for
developers on Windows.

Thanks to Wavesonics who reported this on irc.

Signed-off-by: Mark Harris <mark.hsj@gmail.com>
This commit is contained in:
Ralph Giles 2020-05-30 21:17:36 -07:00
parent 4d40636748
commit 1168a29ecd
No known key found for this signature in database
GPG key ID: 9259A8F2D2D44C84

View file

@ -85,7 +85,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
inFile = argv[1];
fin = fopen(inFile, "r");
fin = fopen(inFile, "rb");
if (fin==NULL)
{
fprintf(stderr, "failed to open input file: %s\n", strerror(errno));
@ -101,7 +101,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
outFile = argv[2];
fout = fopen(outFile, "w");
fout = fopen(outFile, "wb");
if (fout==NULL)
{
fprintf(stderr, "failed to open output file: %s\n", strerror(errno));