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 are the different file extensions involved when programming in C?
What does emoji p mean?
What language is c written?
Write a program to check palindrome number in c programming?
What are the functions to open and close the file in c language?
What are the general description for loop statement and available loop types in c?
Explain 'far' and 'near' pointers in c.
What is sizeof array in c?
Do you know the difference between malloc() and calloc() function?
How can I dynamically allocate arrays?
Which control loop is recommended if you have to execute set of statements for fixed number of times?
Explain about the functions strcat() and strcmp()?
Why does notstrcat(string, "!");Work?
Is it better to use a macro or a function?
How do you initialize pointer variables?