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
Can you please explain the difference between static and dynamic binding of functions?
How do I start a c++ project?
Explain the isa and hasa class relationships.
How do I use turbo c++?
Is there a sort function in c++?
Is c better than c++?
What is enum c++?
Do class method definitions?
Show the declaration for a static member variable.
If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?
Is overriding possible in c++?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
What is name hiding in c++?
What is the difference between a type-specific template friend class and a general template friend class?
What is c++ best used for?