Write a function which takes a character array as input and
reverses it in place.

Answer Posted / gumnam

void reverse(char *a)
{
char tmp;
int len = strlen(a) - 1;

for (int i = 0; i < len/2; i++)
{
tmp = a[i];
a[i] = a[len - i];
a[len - i] = tmp;
}
}

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Comment on local and global scope of a variable.

671


What is the cout in c++?

658


Why c++ is called oop?

697


Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

1593


What is a memory leak c++?

668






What is basic if statement syntax?

646


What is ostream in c++?

653


Is java a c++?

656


What are pointers used for c++?

671


How many namespaces are there in c++?

643


When do we run a shell in the unix system?

673


What is the function to call to turn an ascii string into a long?

697


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

807


What is jump statement in C++?

703


what is upcasting in C++?

825