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
What is the difference between text files and binary files?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
What is bin sh c?
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
swap 2 numbers without using third variable?
What is the importance of c in your views?
What is the general form of #line preprocessor?
What is this infamous null pointer, anyway?
Is c pass by value or reference?
What is the difference between test design and test case design?
Explain how can you tell whether a program was compiled using c versus c++?
Why clrscr is used in c?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
What is "Hungarian Notation"?
What is an array? What the different types of arrays in c?