Explore BrainMass

Extracting a certain text file from a file

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

See the attached file.
I have a text file containing sentences and random sequences of letters, symbols and numbers. I have to write a program that will extract only the text sent to a particular device and ignore the rest of the messages. Each message sent has an identifying two characters header (first being a $ followed by a single character) followed by a two digit number indicating the size of the message followed by the message itself. I have to extract out only the set of messages (lines of text) addressed to me. Ex) My identifying two characters is $Y so the program will only extract messages sent to $Y devices.

Example input:
oprfjiad093$X5abcdep0qj3 fqijfpiqjef$Y21Your message to find.p9iqjv0$Ea0n wq9r r$Y13Next Message.09q 4r9 qefkjad0fu8;lkfdv98

Example output:
Your message to find.
Next Message.

I figured out how to store the text from the text file into a character array and display said text. I just can't find out to control what characters get displayed. Is there a special if statement or something? An example of something like this would be appreciated.

© BrainMass Inc. brainmass.com March 22, 2019, 1:09 am ad1c9bdddf


Solution Preview

You need to write a loop for this one. I will give you the algorithm and some hints, and you can try to work it out from there.

The idea is to use InputFile.get(). Do not read them all at once because you never know whether the message.txt will contain less than 1174 characters or not.

Instead, read from the beginning one char at a time. ...

Solution Summary

This solution gives an outline for this problem. It goes through some basic techniques that can be used in file processing, and provide a rough algorithm on solving this particular problem. There is no source code attached.