char 배열 (파일 아님)을 압축하고 압축을 풀 수있는 zlib.h deflate 및 inflate 함수를 구현하려고합니다.deflate and inflate (zlib.h) in C
다음 구문이 올바른지 알고 싶습니다. 뭔가 빠졌거나 잘못 정의 했습니까?
char a[50] = "Hello World!";
char b[50];
char c[50];
// deflate
// zlib struct
z_stream defstream;
defstream.zalloc = Z_NULL;
defstream.zfree = Z_NULL;
defstream.opaque = Z_NULL;
defstream.avail_in = (uInt)sizeof(a); // size of input
defstream.next_in = (Bytef *)a; // input char array
defstream.avail_out = (uInt)sizeof(b); // size of output
defstream.next_out = (Bytef *)b; // output char array
deflateInit(&defstream, Z_DEFAULT_COMPRESSION);
deflate(&defstream, Z_FINISH);
deflateEnd(&defstream);
printf("Deflate:\n%lu\n%s\n", strlen(b), b);
// inflate
// zlib struct
z_stream infstream;
infstream.zalloc = Z_NULL;
infstream.zfree = Z_NULL;
infstream.opaque = Z_NULL;
infstream.avail_in = (uInt)sizeof(b); // size of input
infstream.next_in = (Bytef *)b; // input char array
infstream.avail_out = (uInt)sizeof(c); // size of output
infstream.next_out = (Bytef *)c; // output char array
inflateInit(&infstream);
inflate(&infstream, Z_NO_FLUSH);
inflateEnd(&infstream);
printf("Inflate:\n%lu\n%s\n", strlen(c), c);
작동하지 않기 때문에 묻는 중입니까? 어떤 종류의 오류 메시지가 나타 납니까? – larsks
@larsks 경고없이 컴파일되지만 필자가 선택한 함수와 정의가 의미가 있는지 또는 다른 함수를 사용해야하는지 알고 싶습니다. –
알았어요. 질문을 명확히 해 주셔서 감사합니다. – larsks