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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!