program for swapping two strings by using pointers in c language

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

In which language linux is written?

591


What does 3 mean in texting?

602


What is the use of printf() and scanf() functions?

618


Is it possible to execute code even after the program exits the main() function?

800


code for find determinent of amatrix

1505






What is null in c?

588


What is include directive in c?

633


Where static variables are stored in memory in c?

513


what is the structure pointer?

1636


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

925


Explain continue keyword in c

575


What is the scope of global variable in c?

547


how is the examination pattern?

1587


1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.

1650


Which of these functions is safer to use : fgets(), gets()? Why?

626