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
Can a pointer point to null?
What is structure packing in c?
Can 'this' pointer by used in the constructor?
What is the difference between c &c++?
Is fortran faster than c?
What is #include cctype?
What is a nested loop?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
Tell me what is the purpose of 'register' keyword in c language?
What is identifiers in c with examples?
What is a static function in c?
Explain how do you determine the length of a string value that was stored in a variable?
What is declaration and definition in c?
When a c file is executed there are many files that are automatically opened what are they files?