Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are required to write a C program - whose input is an existing text file with a name specified in a command line as

You are required to write a C program

- whose input is an existing text file with a name specified in a command line as the first argument,

- whose output is a new text file with a name specified in a command line as the second argument; requirements to the new text file are given below.

Input and output files should have extension .txt but only names of the files are specified in a command line.

Example: suppose the executable version of your program is named p2.out. The program will be executed by a command line of the following form:

p2.out inputfile outputfile

In this case file inputfile.txt must exist, outputfile.txt will be created.

Requirements for the output text file:

The output file should have copy of each line of the input file in the same order of lines. Each line of the output file should consist of the same words as the corresponding line in the input file but ordered backward.

In the input file words are separated by one or more spaces (' ') or by horizontal tab ('\t'). In the output file words should be separated by single space.

In the input and output files, each line ends with new line character ( ). Lines do not exceed 255 characters including new line character.

The outline of your C program is as follows.

1.Read command line arguments and check the correctness.

2.Create a new file named second argument + ".txt"

3.Proceed with converting input file lines into output file lines.

4.Stop and print out "Finished." once finish reading and writing the files.

Thus, each time your program is executed, it should handle just one input file.

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

What are the components of a sound business model?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago