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

write a program to print calender using for loop.

1 Answers   HCL, TCS,


Write a program on swapping (100, 50)

0 Answers   BPL,


Write a Program to accept different goods with the number, price and date of purchase and display them

0 Answers   HDFC,


yogesh patil in dell

3 Answers   DELL,


a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above

0 Answers  


What are formal parameters?

0 Answers  


read the folllowing code # define MAX 100 # define MIN 100 .... .... if(x>MAX) x=1; else if(x<MIN) x=-1; x=50; if the initial value of x=200,what is the vlaue after executing this code? a.200 b.1 c.-1 d.50

4 Answers   TCS,


State the difference between realloc and free.

0 Answers   Aricent,


struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

0 Answers  


helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.

3 Answers  


What are run-time errors?

0 Answers  


What is the proper way of these job Tell me about there full work

0 Answers   EDS,


Categories