Write a program containing the following functions, in this order:
main - calls the other functions; otherwise does almost nothing
getSize - which asks the user how many strings they want
getSpace - which gets an array in the heap of the size requested by the user
inputData - which allows the user to input the strings and stores them
in the array
printData - which prints all the strings, one string per line
destroy - which returns all the space to the heap
All of these functions, except main, shall have a return type of void.
/* Calls the other functions; otherwise does almost nothing */
int main ()
{
int numStrings;
string newArray;
getSize (&numStrings);
getSpace (&numStrings, &newArray);
inputData (&numStrings, &newArray);
return 0;
}
/*getSize - which asks the user how many strings they want */
void getSize (int *numStrings)
{
cout << "How many strings would you like? " << endl;
cin >> *numStrings;
}
/*getSpace - which gets an array in the heap of the size requested by the user */
void getSpace (int *numStrings, string newArray[] )
{
newArray = new string [*numStrings];
}
/* inputData - which allows the user to input the strings and stores them */
void inputData (int *numStrings, string newArray[])
{
string data;
for (int i = 0; i < *numStrings; i++)
{
cout << "Please enter string #" << i << endl;
cin >> data;
newArray[i] = data;
cout << newArray[i] << endl;
}