how to swap two strings without using any third variable ?

Answer Posted / rohit kapade

bool SwapString(char **s1,char **s2)
{
//char *temp = NULL;
//temp = *s1;
//*s1 = *s2;
//*s2 = temp;
*s1 = (char*)((int)*s1 + (int)*s2);
*s2 = (char*)((int)*s1 - (int)*s2);
*s1 = (char*)((int)*s1 - (int)*s2);
return true;
}

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which coding certification is best?

563


What is the fastest c++ compiler?

577


If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?

658


How can virtual functions in c++ be implemented?

602


What is a lambda function c++?

547






What is difference between malloc()/free() and new/delete?

641


A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.

3402


Define a nested class.

608


What is c++ iterator?

631


What is difference between n and endl in c++?

576


What is flush () in c++?

575


What is the difference between structure and class?

544


why is iostream::eof inside a loop condition considered wrong?

586


Is it possible to write a c++ template to check for a function's existence?

568


what is scupper?

1886