Search for question
Question

* Complete the user-defined library "functions.h":

Add the include guard.

Define the following functions:

▪readAlphabetFromFile: this function receives the filename (string) and the variable to store the alphabet. The function opens the file specified by the first parameter and stores its contents in the variable specified by the second parameter. Finally, the function returns an integer value (0 if the previous

operation succeeded or -1 if the function cannot open the file).

• printAlphabet: this function receives the alphabet and 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.

printHistogram: this function receives the alphabet and prints the information about the frequency of the symbols in the message. You must print the information about the frequency of 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.

printCodes this function receives the alphabet and prints the information about the codes of the symbols in the message. You must print the information about the codes of 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.

totalNumberOfBits: this function receives the alphabet and returns the number of bits used to represent the message generated by the alphabet. To calculate the total number of bits, you must accumulate the number of bits used to represent each symbol in the message (number of bits of the

symbol "frequency of the symbol).

Complete the provided main.cpp file.

o include the user-defined library.

Decide how you are going to store the information about the alphabet.

Given the following structure

struct symbol

{

};

char characters

Int froquency:

string code;

You must use this structure to define the variable that holds the information about the alphabet. You are allowed to use a static amay, a dynamic array, or a vector of the data type "symbol".

Call the user-defined functions readAlphabetFromFile, printAlphabet, printHistogram, printCodes, and totalNumberOfBits

Complete the instructions based on the comments in the template file (main.cpp).

Input:

1. A string representing the filename. This file has all the information about the alphabet.

Example input lat

Each line of the input file contains information about a symbol (symbol, frequency, and binary code). Here is an example of the input file

A5 2013

8 7 181

Cz 18001

0818

E 3 18111

The symbol is represented by a single character, the frequency is represented by a positive integer value, and the code is represented by a string with ones and zeros. A single white space is used to separate the elements of the symbol.

Given

Numbe

Chara

Histo

Alpha

CES

02

Total

NO