Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Implement the lab using procedural programming techniques only. That is, you are not allowed to define classes or objects. Diff. Implement a program that

C++

Implement the lab using procedural programming techniques only. That is, you are not allowed to define classes or objects.

Diff. Implement a program that compares two text files character-by-character. The program should output the line numbers that contain different characters and the place where the two lines start to differ (the difference is denoted by ^ (caret) character. If both files are identical, the program should output nothing.

File lengths may differ. If one file is shorter than the other, the shorter file is assumed to have empty lines, i.e. the extra lines of the longer file are considered different from the empty lines of the shorter file.

The file names should be passed as arguments on the command line. Assume the files exist. Assume the file names are the same length. If your program is not invoked with two arguments, it should print an error message and quit. The program operation should look like this:

 prompt% diff file1.txt file2.txt file1.txt: 20: Hello file2.txt: 20: Hallo ^ file1.txt: 25: World???? file2.txt: 25: World! ^ 

where 20 and 25 are line numbers.

You are allowed to use getline() and string comparison functions in the implementation of this project.

Hint. The command line arguments are input as C-style strings arguments to main(). See this program for an example of handling them.

To configure command-line arguments for an MS Visual Studio project, right-click Solution Explorer, select "properties" from the drop-down menu, go to Configuration Properties Debugging and set "Command Arguments" in the properties list.

To create a string of spaces of a particular length use this form of initialization: string spaceString(length, ' '); or use assign operator: spaceString.assign(length, ' ');

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

Discuss the legal implications involved in writing credit refusals.

Answered: 1 week ago

Question

2. Compare the sales and service departments at Auto World.

Answered: 1 week ago