Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I swap two strings using two variable only?
Posted
Comments
Wendelius 24-Aug-12 16:35pm    
Why would you need to do that? Having an extra variable typically causes no more memory useage than swapping the variable contents
pasztorpisti 24-Aug-12 20:24pm    
Its possible and absolutely usless. What do you want to do with this?

Impossible. You cannot. You need somewhere to store one value while it's overwritten by the other
 
Share this answer
 
I think it is possible..look below..
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);
 
Share this answer
 
Comments
Herambashree 27-Aug-12 9:56am    
Than you . It is working Sir.
ridoy 27-Aug-12 12:00pm    
glad to help you..mark it as answer if you think it solves your problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900