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

  How to call a function from main

Call a function from main(), passing one value to it. Return TWO values, both the square of the number and the number to the power of three.

  Question 1 use the attached database to provide the

question 1 use the attached database to provide the relational algebra which would list the requested information

  Calculate the balance by adding deposits

Display the new balance in a ReadOnly text box or a label. Calculate the balance by adding deposits and subtracting service charges and checks. Include buttons for Calculate, Clear, and Exit.

  Recursive method void printrevers

Write a c language program and I also need executable file for this program - Write a recursive method

  Create a program that would give you the day of the week

Create a program that would give you the day of the week if you entered month/date/year. please show every step.

  Implement the recursive version of the binary search

Write the code to test it out on a sample input. Compare its complexity with the iterative version found in the text book.

  The grid is populated randomly

Initially, the grid is populated randomly with occupied and empty cells. Once the initial grid has been created, the program loops. Each iteration of the loop represents a tick or time step in the environment.

  This function should accept a two-dimensional

getLowestInRow. This function should accept a two-dimensional array as its argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the lowest value in the specif..

  Write in c++. read an inputfile.txt

write in C++.  read an inputFile.txt which contains integers that are virutal addresses, and I am suppossed to translate that into physical addresses using a page table and a transition lookaside buffer

  Write a program that allows a user to enter 12 double values

Write a program that allows a user to enter 12 double values representing store sales for each month of one year. After all 12 values are entered,

  Calculate the total of a purchase from a farmer''s market

You will develop a program that can calculate the total of a purchase from a farmer's market that sells apples, bananas, and oranges. At this particular market, apples are $1.99/lb., bananas are $0.99/lb., and oranges are $1.50/lb. Users should be..

  Write the prototype and header for a function

Write the prototype and header for a function called calculate. The function should have three parameters: an int, a reference to a double, and a long (not necessarily in that order). Only the int parameter should have a default argument, which is..

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