Question
I am writing in C++ creating the files on command line. Create a file called reverse.h that contains the prototype for afunction that reverses the
I am writing in C++ creating the files on command line.
Create a file called reverse.h that contains the prototype for afunction that reverses the
characters of a C++ string:
string reverse (const string & str);
4. Create a file called reverse.cpp that contains theimplementation the function prototyped in
reverse.h. This function should reverse the characters of the C++string passed to it and
return a C++ string containing the reversed string. (30points)
5. Create a file called Ex13.cpp. This will be the application filefor this lab. You will be
submitting this file at the end of this exercise. (30 points) Theprogram should:
a. include iostream, fstream, strstream, and cstdlib
(These libraries are for hints. If you find a better library toopen file, break string,
etc. feel free to use those.)
b. include reverse.h
c. accept command line arguments
d. for each file listed on the command line following the name ofthe executable
i. print the name of the file
ii. open the file
iii. read the file line by line
iv. reverse each line of the file
v. write out the original line and the reversed line
vi. break the reversed line into white space delimited string andwrite each
string on a separate line.
6. Create a makefile to create an executable called Ex13.out. Yourmakefile should compile and
link Ex13.cpp and reverse.cpp. (30 points)
7. Execute your program using the names of the .in files as thecommand line arguments. Your output should look
something like:
File: file1.in
I think that I shall never see
ees reven llahs I taht kniht I
ees
reven
llahs
I
taht
kniht
I
The file that we are reading is named file1.in and the contentsare below-
I think that I shall never see
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started