Problem:Given your knowledge of static amays, functions, fe 1/0, and structures, you are asked to write C= program to decompress a fil based on the information 3bout an alphabet stored in 2...

I need help with this assignment and it us due tonight


Problem: Given your knowledge of static amays, functions, fe 1/0, and structures, you are asked to write C= program to decompress a fil based on the information 3bout an alphabet stored in 2 fe. Given the following structure: struc symbol « ear character; ant frequency; string code; 5 Here are the tasks you must complete for this programming assignment: + Complete the user-defined library “unctions hs © Add the include guar. © Define the following functions: = reagAlpnabetFrom Fie: ts function receives the filename (string) 3nd the varizble to store the alphabet (struct symbol]. The function opens tne file specied by the first parameter and stores fs contents In the variable spec ed by the second parameter. Finally, the function returns an Integer value (ine number of symbols In the alphabet ifthe previous operation succeeded or zero if the function cannot open the fie). = printAlphabet; this function recelves the alphabet (struct symbol] and the number of symbols In the alphabet (in). This function prints the information about the symbols in the message. You must print the information about the symbols In the alphabet based on the order they appear in the input file. You must use the output messages based on the example below. This function does not return any value. = cecompressFile: ths function receives the name of the compressed lle (string), the alphabet [struct symbol, 3nd the number of symbols in the alphabet (int) The compressed fle has the folowing format (ses the example below): = A string that represents the binary code of the symbol. = Alstof n integers (where n s the frequency of the symbol) representing the positions where the symbol appears in the message. (Given the information n the compresses fle ang the alphabet, i's function stores the cecompressed message I 3 file named decom pressed. The function returms a boolean value (true 1 the compresses and decom pressed fles can be opened or alse otherwise). = snowDecompresseaFie: ts function receives the name of the decompressed fle (string). Tis function opens tne file (received as a parameter) and stores ts contents n a string. Finally, ths function returns the string with the decompresseg message (it returns an empty string f the fle cannot be opens). * Complete the provided main.cpp fie. © Incluce the user-gefined brary. © Declare a static array of symbols to store the alphabet. © Call the user-defined functions readAlphabetFromFie, printAlphaet, decom pressfie, and showDecompressedFile. Input: 1. A string representing the lense. Ts fe has 31 ne information sbout te phabet Sram putt nt E2cn ine of the input fle contains information 3bout 2 symbol (symbol frequency, and binary code). Here is an example of tne input fle: The symbol i represented by @ single character, tne frequency represented by @ positive integer value, and the code Is represented by a string with ones and zeros. A single white space used to separate the elements of the symbol. 2. Astring representing the compressed flename. This fle has al the information about the compressed codes. Example: compfi.at To decompress the file, your program: 3) reac each ine of the compressed file, b) translates tne binary code to the corresponding character (using the alphabet), ¢) stores the decoded character nto 3 string (using the fst of positions from the compressed lle), and c stores the string with the orginal message In a le [decompressed.ix). Given the previous fle, we have the following: The binary code 11 s decoded into the letter A and stored In positions 1,3, and 5 of the string with the origina! message. The binary code Dis decoded into the letter C and stored In positions 0, 2, and 4 of tne sting with the original message. The binary code 101s decoded into the letter D 3nd stored In positions § 3nd 8 of the string with the original message. The binary coge 1001s decoded into the leter 8 and stored in position 7 of the string with the original message. The final original message 5: CACACADED Output: Given the input and compressed fle presented before, the expected output atpraser Symbol: A, Frequency: 3, Code: 11 Symbol: C, Frequency: 3, Code: © Symbol: 8, Frequency: 1, Code: 160 Symbol: 0, Frequency: 2, Code: 161 Original sessage: CACACADSD NOTES: © You can safely assume that the input wil always be valid. © Use the comments available n the template files to complete your solution. © You can define additional functions i needed.
Mar 20, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here