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 |
What is a lookup table in c?
Explain null pointer.
How do you access command-line arguments?
CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.
Why is sizeof () an operator and not a function?
What are the different types of pointers used in c language?
Why header file is used in c?
What is the difference b/w Structure & Union?
Can you please explain the difference between syntax vs logical error?
Write an algorithm for a program that receives an integer as input and outputs the product of of its digits. E.g. 1234 = 24, 705 = 0
Explain what header files do I need in order to define the standard library functions I use?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].