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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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