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
What is c standard library?
Why doesn't C support function overloading?
Do you know null pointer?
How do we print only part of a string in c?
What is the use of sizeof () in c?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
how to write optimum code to divide a 50 digit number with a 25 digit number??
When should the const modifier be used?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
Can we change the value of static variable in c?
Explain threaded binary trees?
Explain what is operator promotion?
What is strcmp in c?
Explain what is #line used for?
What is difference between static and global variable in c?