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
What are 'near' and 'far' pointers?
Write a C program to count the number of email on text
Explain what are run-time errors?
Tell us the use of fflush() function in c language?
Write a program of advanced Fibonacci series.
write a c program in such a way that if we enter the today date the output should be next day's date.
What is the translation phases used in c language?
What is main function in c?
What does %c do in c?
Write programs for String Reversal & Palindrome check
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
Should I learn data structures in c or python?
What is typedef struct in c?
What is d scanf?
What is the difference between text and binary modes?