How to write a program for swapping two strings without
using 3rd variable and without using string functions.
Answer Posted / gaurav rustagi
#include <iostream>
#include <string.h>
using namespace std;
void swap ( char ** , char ** ) ;
int main ()
{
char * buyer= "US Dollars" ;
char * seller = "IN Ruppees" ;
cout << "Before swap, buyer has " << buyer;
cout << " and seller has " << seller << endl;
swap (buyer,seller);
cout << " After swap, buyer has " << buyer;
cout << " and seller has " << seller << endl;
return 0;
}
void swap ( char ** L , char ** R )
{
char ** temp = R;
R = L ;
L = temp ;
}
Is This Answer Correct ? | 7 Yes | 13 No |
Post New Answer View All Answers
How variables are declared in c?
Where register variables are stored in c?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
What is the use of structure padding in c?
Where static variables are stored in memory in c?
What is difference between structure and union?
What does the error message "DGROUP exceeds 64K" mean?
what is the diffrenet bettwen HTTP and internet protocol
Which is better malloc or calloc?
Is exit(status) truly equivalent to returning the same status from main?
Why double pointer is used in c?
What are the application of void data type in c?
What is a good way to implement complex numbers in c?
What are reserved words with a programming language?
Is c a great language, or what?