Question
Instructions: write a short program to allocate a string dynamically, asking the user how long the string needs to be. It will then allocate just
Instructions: write a short program to allocate a string dynamically, asking the user how long the string needs to be. It will then allocate just that amount of memory. Complete the code below by filling in the missing C++ code. As before, you are free to make up the exact input.
Fill in blanks, add code as needed, etc.
#include ___________________
using namespace std;
void main ( )
{
char _________________; // Pointer to a c-string
int length;
cout << endl;
<< Enter the number of characters in the string: ;
cin >> length;
// Allocate memory for the string. Remember to allow
// space for the string delimeter.
____________________________________________________
// Read in and echo the string.
cout << Enter the string (no blanks allowed): ;
cin >> _______________________;
cout << Input String: << _________________ << endl;
// Deallocate the memory used to store the string.
__________________________________
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