program for swapping two strings by using pointers in c language



program for swapping two strings by using pointers in c language ..

Answer / umesh

#include <stdio.h>
void fastSwap (char **k, char **l)
{
char *t = *k;
*k = *l;
*l = t;
}
int main ()
{
char num1[] = "abc";
char num2[] = "def";
fastSwap ((char**)&num1,(char**)&num2);
printf ("%s\n",num1);
printf ("%s\n",num2);
return 0;
}

Is This Answer Correct ?    9 Yes 8 No

Post New Answer

More C Interview Questions

I came across some code that puts a (void) cast before each call to printf. Why?

0 Answers  


what is real time system?what is the differance between hard and soft real time systems

2 Answers  


How can I read a directory in a C program?

2 Answers   Bright Outdoor, Wipro,


Difference between goto, long jmp() and setjmp()?

0 Answers   EXL,


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

0 Answers   Genpact,






What are the 4 types of programming language?

0 Answers  


write a own function for strstr

1 Answers   LG Soft,


what is disadvantage of pointer in C

13 Answers   Tech Mahindra,


What is volatile c?

0 Answers  


1.)how to find d most repeated word in a string? string ="how do you do"?? output should be do

1 Answers   AAS, Nagarro, Vuram,


Explain built-in function?

0 Answers  


What is the difference between array and pointer?

0 Answers  


Categories