Question
For this assignment you will be implementing the decoding side of RLE. Write a program that prompts the user to enter a filename containing the
For this assignment you will be implementing the decoding side of RLE. Write a program that prompts the user to enter a filename containing the RLE pairs of count character. Then open the file. If the file does not exists, print out an error message. If the file does exist, iterate through it from beginning to end reading each count and character pair. For each count/char pair, output the appropriate number of the character to stdout (use cout). Use the sample runs to ensure all of your output is correct.
To make reading pairs from the input files easier, the files will contain whitespace between all counts and characters of the input. For example, instead of 7a6b4a3b5c as the input, the file would contain the information as 7 a 6 b 4 a 3 b 5 c. (all separated by a single space character). This is important to remember! The reason it will be this way is to save the trouble of figuring out what some input similar to 1201a would be. Is it 12 0's and 1 a? or is it 1201 a's? etc. By including spaces between all integer and character pairs the processing becomes easier. However, you will also need to make use of .get(ch) to "throw out" the irrelavent spaces. With stdin you would have used std::cin.get(ch), however with file objects remember you will need to use file_obj.get(ch) .
Program Requirements
- Include all appropriate comments as usual.
- Do not forget to close the file after you are done with it.
- You must use a while loop to handle the loop reading information from the file.
- You must use a for loop to handle the count/char output.
- Use the sample runs to ensure that all output is spelled/spaced correctly.For this assignment you will be implementing the decoding side of RLE. Write a program that prompts the user to enter a filename containing the RLE pairs of count character. Then open the file. If the file does not exists, print out an error message. If the file does exist, iterate through it from beginning to end reading each count and character pair. For each count/char pair, output the appropriate number of the character to stdout (use cout). Use the sample runs to ensure all of your output is correct.To make reading pairs from the input files easier, the files will contain whitespace between all counts and characters of the input. For example, instead of 7a6b4a3b5c as the input, the file would contain the information as 7 a 6 b 4 a 3 b 5 c. (all separated by a single space character). This is important to remember! The reason it will be this way is to save the trouble of figuring out what some input similar to 1201a would be. Is it 12 0's and 1 a? or is it 1201 a's? etc. By including spaces between all integer and character pairs the processing becomes easier. However, you will also need to make use of .get(ch) to "throw out" the irrelavent spaces. With stdin you would have used std::cin.get(ch), however with file objects remember you will need to use file_obj.get(ch) . Program Requirements
- Include all appropriate comments as usual.
- Do not forget to close the file after you are done with it.
- You must use a while loop to handle the loop reading information from the file.
- You must use a for loop to handle the count/char output.
- Use the sample runs to ensure that all output is spelled/spaced correctly.
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