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
What is a sequence in c++?
What is linked list in c++?
Explain how a pointer to function can be declared in C++?
What are the benefits of operator overloading?
What is class syntax c++?
What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required
State the difference between pre and post increment/decrement operations.
What is the array and initializing arrays in c++?
What is encapsulation in c++?
What do you mean by late binding?
What is the difference between c++ and turbo c++?
Are c and c++ similar?
Is the declaration of a class its interface or its implementation?
Can non graphic characters be used and processed in C++?
What is while loops?