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 would you use the functions fseek(), freed(), fwrite() and ftell()?
What are the different categories of functions in c?
When should the volatile modifier be used?
What is pre-emptive data structure and explain it with example?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
Why c is called a mid level programming language?
Difference between Function to pointer and pointer to function
How do I use void main?
What are the 5 types of inheritance in c ++?
What is difference between union and structure in c?
Why is c so popular?
Explain what is the difference between #include and #include 'file' ?
What is page thrashing?
Why is c called a structured programming language?
What is huge pointer in c?