For this assignment you will write a program that reads a


For this assignment you will write a program that reads a source file, edits the file based on a second file containing commands, and then saves the resulting text to a third file. You will find my executable and test files in ~davis/40/p7.

1. Files
1.1. The names of the three files are passed as command line arguments in the following order: source file name, command file name, and destination file name.

1.2. Source File

1.2.1.Contains an unlimited amount of text with ‘\n' at the end of each line. Use the getline method described in the string chapter.

1.3. Command File

1.3.1.Each line in the command file contains exactly one command.
1.3.2.The command file is guaranteed to be error free. All line numbers will be that of existing lines.

2. Commands
2.1. There is exactly one space between each element in a command line.
2.2. {char}* indicates a string of zero or more chars of any length, with spaces allowed.
2.3. Line numbers start at zero. The line number of specific text can change during the editing process because of line
insertions and deletions.
2.4. Insert

2.4.1.Syntax: I {char}*
2.4.2.Operation: inserts the char(s) in the line number specified, starting at the position specified.
2.5. Replace

2.5.1.Syntax: R {char}*
2.5.2.Operation: replaces the char(s) in the line number specified, between the two positions, inclusive, with the
string specified.
2.6. Find

2.6.1.Syntax: F {char}*
2.6.2.Operation: Prints the string to screen and follows it with the line numbers of all lines that contain the
specified string, each separated by a single space.
2.7. Delete line(s)

2.7.1.Syntax: D
2.7.2.Operation: Deletes the lines specified, inclusive. The text will need to move up to fill the resulting gap.
2.8. Erase word(s)

2.8.1.Syntax: E {char}*
2.8.2.Operation: removes the specified string from the entire text. If this matches an entire line, then the entire
line should be removed.
2.9. Copy and paste

2.9.1.Syntax: C <
2.9.2.Operation: Copies the specified lines and pastes them starting at the destination line number.
2.10. Move

2.10.1. Syntax: M
2.10.2. Operation: Cuts the specified lines and pastes them starting at the destination line number. The
destination line number is based on the original vector before the lines are cut.

3. Further specifications:
3.1. The text must be stored in a vector of STL strings.
3.2. You may not #include , , nor .
3.3. You may not declare any arrays.
3.4. You may not use the [] operators of the vector and string classes, nor may you use the "at" method. You must use iterators instead. Hint: You can use a for loop to set the iterator to the correct position within the array.
[ssdavis@lect1 private]$ cat limerick.txt
A Limerick by Grady Tibboel I've been studying all night and I'm tired, But I can't sleep because I'm so wired. So I'll play on the net
'Stead of going to bed, And my tests will seem a quagmire.
[ssdavis@lect1 private]$ cat commands.txt
I 2 18 ECS 40
I 4 23 until dawn,
R 6 7 12 midterms
R 3 9 11 not
F I'
F y
F STL
D 1 1
D 3 4
E I'm
E A Limerick by Grady Tibboel
[ssdavis@lect1 private]$ p7.out limerick.txt commands.txt results.txt
I' 2 3 4
y 0 2 4 6
STL
[ssdavis@lect1 private]$ cat results.txt
I've been studying ECS 40 all night and tired,
But I cannot sleep because so wired.
And my midterms will seem a quagmire.
[ssdavis@lect1 private]$ cat commands2.txt
C 0 3 6
C 8 8 10
M 0 0 2
M 4 5 6
[ssdavis@lect1 private]$ p7.out limerick.txt commands2.txt results2.txt
[ssdavis@lect1 private]$ cat results2.txt

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: For this assignment you will write a program that reads a
Reference No:- TGS01034184

Expected delivery within 24 Hours