Ask C/C++ Expert


Home >> C/C++

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

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91333877
  • Price:- $50

Guranteed 36 Hours Delivery, In Price:- $50

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As