Question: C++ #include using namespace std; int main(int argc, char* argv[]) { //print cmd line arguments for (int i = 0; i < argc; i++) {
C++
#include using namespace std;
int main(int argc, char* argv[])
{ //print cmd line arguments
for (int i = 0; i < argc; i++) {
cout << endl << argv[i];
} cout << endl; return 0;
}
Perform the following tasks to the code above
1.Add a preprocessor directive to include the string class.
2. Declare a string pointer named args at the top of the main function.
3. Create a dynamic array of strings that has the same size as argv does.
4. Using a for loop, set each string in args to a corresponding C-string in argv.
You can convert a C-string to a string simply by assigning the C-string to the string.
5. Change the code to print out from the args array instead of the argv array.
6. Add a line just before the return statement to delete the args array.
7. Add lines in the code to print out the value and the address of args in the following spots ::_ after the declaration of args, after creating the dynamic array, after filling the array with strings, after deleting the array
8. set args to NULL after the deletion statement
/////Please help. I am stuck in doing the above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
