Swap Two Values ​​without Temporary Variable

xiaoxiao2021-03-05  30

INT A, B; A ^ = B; B ^ = a; a ^ = b; Note: IF a and b are Pointers. This Behavior Probably Will Not Work Well. Assume That A and B Are Pointing to the Same Varible Simultaneously, if we do as the above, the result will be 0. In a conclusion, what if we meet the following cases the kinda method will not work well. first, the object a and object b have shared part of memory. second, either a OR B Is Stored in The Register or Is in Bitfall.

转载请注明原文地址:https://www.9cbs.com/read-33935.html

New Post(0)