sorry for the post but my team is doing an internet scavenger hunt. part of it is a C++ quiz. need help with the following questions, Help !
Consider this C++ code fragment for questions #4 and #5.
char *stringmult(int n)
{
char *x= "hello ";
for (int i = 0; i < n; ++i)
{
char *y = new char[strlen(x) * 2];
strcpy(y, x);
strcat(y, x);
delete[] x;
x = y;
}
return x;
}
4) Which of the following are flaws in this routine?
A) Memory leak
B) Buffer overrun
C) Deallocation of non-heap object
D) Does not terminate
E) Use of recursion
F) Crashes if n is negative
5. Once flaws, if any, are corrected in the C++ routine above, what is the performance of its algorithm?