Question
Professor Potter has left a secret message, of unknown length, encoded in file msg.dat for you to unravel. The setup is simple: each line of
Professor Potter has left a secret message, of unknown length, encoded in file msg.dat
for you to unravel. The setup is simple: each line of the file contains one char and one nonnegative integer. The key to reading the message is organizing the characters in the proper order. The integer indicates the position of the character within the message. For example:
e 2
b 1
a 3
h 5
c 4
spells 'beach' when unraveled.
In C++, using a linked list , write a program that will:
1) ask the user for the name of a file, opening and reading this file exactly once
2) unravel and display the message
3) offer to do it again on another file
Notes:
You should check to see that the file exists and contains some data. While debugging your program you may wish to use a shorter file. Also note that some of the characters in the message will be blank spaces or punctuation.
msg.dat file:
3355080183652358541221341 97905693 27 9640012 464 3539234134141 1 5332 2 3 3 1 1 41122 434. 1 4 2 0 4 3 2 4 5 5 15 258 t'. u sn enrc dotoo ,naoh.1 emplo egtom_wYtsae y tmhosge 3355080183652358541221341 97905693 27 9640012 464 3539234134141 1 5332 2 3 3 1 1 41122 434. 1 4 2 0 4 3 2 4 5 5 15 258 t'. u sn enrc dotoo ,naoh.1 emplo egtom_wYtsae y tmhosgeStep 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