how to swap two strings without using any third variable ?

Answer Posted / chitranshu asthana

char* s1 = "Hello";
char* s2 = "World";
s1 = (char*)((int)s1 + (int)s2);
s2 = (char*)((int)s1 -(int) s2);
s1 = (char*)((int)s1 - (int)s2);
printf("%s:%s", s1, s2);

Is This Answer Correct ?    91 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c++ prototype?

580


Can we get the value of ios format flags?

655


Show the declaration for a static member variable.

518


If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?

632


Can comments be longer than one line?

611






What is function prototyping?

613


What apps are written in c++?

595


What is bubble sort c++?

566


Explain register storage specifier.

582


Which bit wise operator is suitable for putting on a particular bit in a number?

711


Will a C compiler always compile C++ code a) Yes b) No c) Only optimized compilers

606


How do c++ struct differs from the c++ class?

583


Differentiate between the message and method in c++?

602


Explain selection sorting. Also write an example.

575


Write about the retrieval of n number of objects during the process of delete[]p?

564