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


Please Help Members By Posting Answers For Below Questions

What are logical errors and how does it differ from syntax errors?

665


write a c program for swapping two strings using pointer

2100


How can I invoke another program or command and trap its output?

621


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

1883


What does p mean in physics?

592






In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]

1963


What is the difference between procedural and functional programming?

525


i have a written test for microland please give me test pattern

2191


How can you pass an array to a function by value?

611


Why is struct padding needed?

639


Who developed c language?

644


Why is sizeof () an operator and not a function?

596


Explain what is wrong with this program statement?

627


What is the use of header?

630


Is it possible to have a function as a parameter in another function?

604