The difference between writing a compressed file

I am using the zlib library to compress my files for my project. I have compressed file content that is 204 characters long. when I tried to write files in two different ways, I get different character lengths as the contents in the file.

When I used

FILE* dest = fopen("D:\File.gz", "w"); to open the destination file

and writes with

int count = fwrite(buffer, 1, size, dest);

The final length of the contents of the file is 205.

When I used

FILE * dest = stdout; and 
int count = fwrite(buffer, 1, size, dest);

I got the correct file size as 204.

Why am I getting 2 different behaviors? Using the first method, the created file cannot decompress and displays an invalid zip file.

+4
source share

Source: https://habr.com/ru/post/1606382/


All Articles