Question: Let f be the following C++ function: void f (char *p) { char *q = p; while (*q) q++; while (p < q) { char

Let f be the following C++ function:


void f (char *p)

{

char *q = p;


while (*q)

q++;

while (p < q) {

char ch = *p;

*p++ = *--q

*q = ch;

}

}



Assume that the argument to f is C-style (null-terminated)string.


A) What modification does f perform to the string that ispassed to it?

B) Explain how f works.

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!