PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs323] flushBits
Date: Saturday, 31 Oct 2020, 18:12:11


    > Message Posted By: Unknown
    >
    > When do you need to call flushBits()?

Suppose that stdin contains one character, and that
encode is running in Stage 3 and has assigned a code to
the empty string.  Then encode will call putBits() to
write one 9-bit code to stdout.  putBits() can only
output the high-order 8 bits of this code and thus must
save the low-order bit for the next call.  But unless
encode calls flushBits() (or does something equivalent),
there will not be a next call and the low-order bit will
never be output.

--Stan-
PREV INDEX NEXT