Question
In this part, you are provided with a file called charP.cpp (shown below) #include using namespace std; extern void reverse(char* p); int main() { char
In this part, you are provided with a file called charP.cpp (shown below)
#include
extern void reverse(char* p);
int main() { char input[50];
cin >> input;
reverse(&input[0]);
cout << input << endl; }
The main function in this file uses a function called reverse(), which is defined in a different file misc.cpp. The reverse() function reverses the a given string. For example, if a string hello is passed as argument to reverse(), the string will be changed to olleh.
Please note:
- Do not change anything in charP.cpp
- The reverse() function must be defined in misc.cpp file(this is a file u need to create)
- Inside reverse() function, you can use *(p+i) to access array element, where p is the char pointer (which points to the begin of the char array) and i is the index value of the element
- When you compile, type
g++ charP.cpp misc.cpp
PART II: Read values from the command line
Write a file arrD.cpp. This program reads in five char values from keyboard, save them into an array, array size is 50. The program then reads an index value, then deletes the value at the given position. In fact, to delete it, the program move all the following values shifted to left. For example, if we have the following values in the array:
Example:
if the user types
a.exe
PLANE
2
The result is: PLNE
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