Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program in main.c in directory unzipper that will be compiled into an executable unzip - per. Your program will read in a
Write a C program in main.c in directory unzipper that will be compiled into an executable unzip
per. Your program will read in a series of bytes in hexadecimal notation, representing the decoding table
needed to decompress a piece of compressed text.
Input
Your program will read its input from stdin. The first line contains a single byte denoting the number of
entries T in the decoding table. This byte is to be interpreted as an unsigned integer. If T is then it is to
be interpreted as This is followed by T lines, each encoding a table entry and consisting of three
items: the character, C that is encoded; the length, Lin bits of the
encoding; and the encoding, E which is bit sequence of L bits. After
the table entries there are four bytes encoding the length of the com
pressed bitstream to be decoded. For Problem these four bytes are
indicating there is no compressed data to follow. In Problem
these four bytes will not be all s
Each entry is encoded as a three byte bit bitstream, where the bits
in each byte are ordered mostsignificant first bit to least significant
last bit The first bits encode the character C The next bits en
code length, L an unsigned integer and the first L bits of the remain
ing bits are the compressed encoding E of character C The three
bytes are encoded in the input in hexadecimal. Hint: Use scanf to
read the bytes For the hexadecimal, use the format specifier with
x On the right is an example of a table for encoding the string
Hello World!
Observe that in this case the encodings for the
characters are between and bits long instead of the full bits per
byte.
Processing
Your program will need to read in the table and output it in a human
readable form.
The decoding table will have at most entries. Use an array
of structs to store the table, as it will be needed for Problem
For each entry, read in the bytes and interpret the bit bit
stream as described above.
The encoding of each character will be at most bits. Any extra bits can be ignored.
Output
All output should be performed to stdout. The output must be exactly as specified. The output consists
of T lines, one line per entry in the table. Each line should be terminated by a newline character. The
entries should be displayed in the same order as the input.
Each entry has the following format:
C : L E
where
C is the character in hexadecimal using the format xx
L is a decimal integer, using the format d
E is the binary representation of the encoding, it should be exactly L characters s and s long.
See example
xa
xxx
xxx
xxx
xc xx
xf xx
xa xa x
xxc x
xxd x
xxe x
xxf x
xxxx
Examples
Input Ex Output Ex Input Ex Output Ex
xa
xxx
xxx
xxx
xc xx
xf xx
xa xa x
xxc x
xxd x
xxe x
xxf x
xxxx
x :
x :
x :
xc :
xf :
xa :
x :
x :
x :
x :
xd
xb xx
xa xx
xxc x
xxe x
xxf x
xa xf x
xxcf xc
xxcf xc
xxbf xc
xxaf xc
xxf xc
xxf xd
xxf xe
xxxx
xb :
xa :
x :
x :
x :
xa :
x :
x :
x :
x :
x :
x :
x :
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started