Question: Write a function called StringToCharBuffer that Takes 2 parameters: a string and a pointer to a pointer to a character. Must dynamically allocate a character

Write a function called StringToCharBuffer that
Takes 2 parameters: a string and a pointer to a pointer to a character.
Must dynamically allocate a character array big enough to store the string (and it's null terminator character) and "return" the array through the pointer to a pointer 2nd parameter
Populate the dynamically allocated character buffer with characters from the first string parameter in reverse order
Use some form of pointer incrementor or pointer arithmetic
The function should work with the following main() code:
int main()
{
char* p;
string s ="!kcoR sredoC";
StringToCharBuffer(s, &p);
cout << p << endl;
delete[] p;
return 0;
}
Submit your *.cpp file and vcxproj file zipped up (Mac users can just submit their *.cpp file).

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!