0

伙计们,

我需要你的帮助。我正在用 C 语言编写一个 lzw 压缩器,但在编码和解码方面遇到了麻烦。这是我到目前为止所拥有的:

fixed it, thanks. 

$> ./encode < input.txt
code 1
code 2
code 3
code 4
code 1

$> ./decode < output.txt (this contains the codes, but as a stream of bits)
read 1
read 2
read 3
read 4

它似乎总是跳过最后一个代码。当我 GDB 时,我看到 C 得到 258 之后,它得到 EOF (-1),我不知道为什么最后一个代码被跳过了。有小费吗?

4

1 回答 1

0

I don't seem to completely understand your question, but here is my 2 cents.

try flushing out the stdout at the end

fflush(stdout);

This might help.

于 2011-09-30T06:03:04.237 回答