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 will you write a code for accessing the length of an array without assigning it to another variable?
How can I call fortran?
Explain high-order and low-order bytes.
What are terms in math?
In C programming, what command or code can be used to determine if a number of odd or even?
What are formal parameters?
What's a good way to check for "close enough" floating-point equality?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
What are header files and explain what are its uses in c programming?
Why can arithmetic operations not be performed on void pointers?
Why is c so popular?
Can a pointer be static?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
What is pointer to pointer in c language?
When c language was developed?