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

Answer Posted / arun

#include<iostream>

using namespace std;

void reverse(char *a)
{
char *tmp = new char[strlen(a)];
memset(tmp,0,strlen(tmp));
int a1 = strlen(a);
a1 =a1-1;
for (int i = a1;i>=0; i--)
{
tmp[a1-i] = a[i];
}
cout<<tmp<<" "<<strlen(tmp)<<endl;
}

void main()
{
char *name = "Xerox";
reverse(name);
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a syntax in c++?

718


daily Routine of father

1015


What is an operator function? Describe the function of an operator function?

718


Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].

690


Write about c++ storage classes?

870






Why do you use the namespace feature?

747


What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator?

726


How can I learn dev c++ programming?

671


Is c++ primer good for beginners?

676


Differentiate between an array and a list?

813


What is type of 'this' pointer?

690


What is an iterator class in c++?

697


What are all predefined data types in c++?

650


What is the difference between function overloading and operator overloading?

663


What is the prototype of printf function?

750