Make a function called \"Allocate\" that would allocate a pointer to a dynamic a
ID: 3624968 • Letter: M
Question
Make a function called "Allocate" that would allocate a pointer to a dynamic array of pointers which would in turn point to a dynamic array of characters. It is okay to use cin>> in this function. Also, find a way to print all the addresses of the double pointer and each element of the array of pointers. Also make a print function. Make this into a complete program with main functionsomebody pleaseee answer it soon!! i need it bad!! will rate lifesaver! and please make sure it works! thank you!
Explanation / Answer
#include <iostream.h>
void Allocate()
{
char **s;
char *p[5];
s=new char* [5];
for(int i=0;i<5;i++)
{
s[i]=new char[4];
cout<<" enter word "<<(i+1)<<": ";
cin>>s[i];
p[i]=s[i];
cout<<endl<<s<<" at "<<(int)p[i];
}
}
int main()
{
Allocate();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.