doc/examples: Always open files as "binary", not "text".

Fixes ticket #8638.
This commit is contained in:
Carl Eugen Hoyos 2020-06-25 00:01:36 +02:00
parent c8ba0daf8d
commit 68f637b6f9
2 changed files with 2 additions and 2 deletions

View File

@ -41,7 +41,7 @@ static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
FILE *f; FILE *f;
int i; int i;
f = fopen(filename,"w"); f = fopen(filename,"wb");
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255); fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
for (i = 0; i < ysize; i++) for (i = 0; i < ysize; i++)
fwrite(buf + i * wrap, 1, xsize, f); fwrite(buf + i * wrap, 1, xsize, f);

View File

@ -223,7 +223,7 @@ int main(int argc, char *argv[])
} }
/* open the file to dump raw data */ /* open the file to dump raw data */
output_file = fopen(argv[3], "w+"); output_file = fopen(argv[3], "w+b");
/* actual decoding and dump the raw data */ /* actual decoding and dump the raw data */
while (ret >= 0) { while (ret >= 0) {