我如何交换字符串 [英] How can i swap strings
本文介绍了我如何交换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何仅使用两个变量交换两个字符串?
How can I swap two strings using two variable only?
推荐答案
不可能.你不能.您需要在某个地方存储一个值,而另一个值会覆盖它.
Impossible. You cannot. You need somewhere to store one value while it''s overwritten by the other
我认为这是可能的.请看下面..
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);
这篇关于我如何交换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文