How to write a program for swapping two strings without
using 3rd variable and without using string functions.
Answer Posted / saptarshi
void main()
{
char *p="string1";
char *q="string2";
p^=q^=p^=q;
printf("%s,%s",p,q);
}
swapping the base pointers of the two strings may work...
if they are declared as character arrays, then it is not
possible as we cannot modify the value of array base
pointers...
| Is This Answer Correct ? | 10 Yes | 26 No |
Post New Answer View All Answers
Why #include is used in c language?
What does c value mean?
Is c object oriented?
Define Array of pointers.
Explain pointer. What are function pointers in C?
what are bit fields? What is the use of bit fields in a structure declaration?
What is quick sort in c?
Can I initialize unions?
What are categories used for in c?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
How can I make sure that my program is the only one accessing a file?
How do I read the arrow keys? What about function keys?
What are control structures? What are the different types?
What is union in c?
Write a program which returns the first non repetitive character in the string?