Program that reads source file

Assignment Help C/C++ Programming
Reference no: EM13764106

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 <line#> <position#> {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 <line#> <start_position#> <end_position#> {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 <start_line#> <end_line#>
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 <<start_line#> <end_line#> <destination_line#>
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 <start_line#> <end_line#> <destination_line#>
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<string.h> , <cstring>, nor <algorithm>.
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

Reference no: EM13764106

Questions Cloud

How has the importance of reading changed from earlier eras : What does literature offer an individual? How has the importance of reading changed from earlier eras (pre-digital/audio/visual media) to our present day?
Critical to the system forensics industry : Explain in your own words the importance of report writing and why you believe it is critical to the system forensics industry. Discuss the need for forensic reports when testifying as an expert witness.
Categories of deterministic forces : Briefly discuss and provide specific examples of the three (3) broad categories of deterministic "forces" that can limit free will and, perhaps, responsibility for criminal acts
Improve the accuracy of eyewitness testimony : debate whether or not eyewitness testimony should continue to be a pillar of the legal system. Suggest one (1) way in which the system can improve the accuracy of eyewitness testimony. Provide a rationale for your response
Program that reads source file : 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.
Programming application that can be written in mat lab : Chose topic in programming application that can be written in Mat Lab code
Legal and ethical leadership and management : Legal and Ethical Leadership and Management, Was it ethical for Normandale to sell the alleged knock-off products at a lower price? Explain
What happe during general motors bankruptcy : Brief (2 pages ) explanation of what happe during General Motors bankruptcy in 2009 and how and why the bankruptcy judge treated the bond holders of GM in a different way than bond holders are normally treated during a corporate bankruptcy
What is most important features of effective communication : What do you consider to be the most important features of effective communication? Explain your choices.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Create the movement of the car from the left to the right

Add the 2 wheels to the vehicle using the GlutWireSphere and create the movement of the car from the left o the screen to the right.

  Program user to enter student names and final grades

Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed.

  The first will be a structure called point

Create two structures. The first will be a structure called Point and will have as its data members an x and y coordinate. The second will be called Line and will have two Point structures as its data members.

  Give a recursive definition of s.

Let S be the set of positive integers that can be written as a sum of one or more 4's and/or 7's. For example, 7 ? S and 18 ? S (because 18 = 4 + 7 + 7)

  Write a function named flattens

Write a function named flattens that takes a two-dimensional array of integers with 100 rows and 200 columns and returns a vector that contains all of the array's elements.

  Write a program that grades the written portion

The local driver's license office has asked you to write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions.

  Using opengl to create a cube

Write a program in C/C++ using OpenGL to create (without using built in function) a cube by implementing translation algorithm by translating along 1. X-axis, 2.Y-axis and 3. X and Y plane

  Write c++ statements that remove all the items

write C++ statements that remove all the items from storeBag and place them into one of two new bags, as follows: Place all occurrences of bread and eggs into fragileBag, and all other items into groceryBag.

  Reads a set of integers from file

The code in file "hw5-stree.cpp" reads a set of integers from file and inserts them into a binary search tree. You are asked to implement two functions max() and depth() that compute the maximum element and the depth of the binary search tree.

  Declare and define constructor

Declare and define constructors and Declare and define destructors - Describe what is an attribute or data member of a class

  Write the class definition for a class called complex

. Write the class definition for a class called complex.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd