What does ^ = mean mean in c / C ++?

I have the following line of code:

contents[pos++] ^= key[shift++]; 

What does the ^= operator mean?

+7
source share
4 answers

This is an XOR assignment statement. Mostly:

 x ^= y; 

matches with:

 x = x ^ y; 
+17
source

This means storing an XOR operation on contents[pos++] using key[shift++] and setting contents[pos++] equal to the result.

Example:

 contents[pos++] 00010101 key[shift++] 10010001 -------- 10000100 
+9
source

This is a bitwise XOR operator.

 x ^= y 

mostly

 x = x ^ y 

of course this is a bitwise operation

http://en.wikipedia.org/wiki/Bitwise_operation

+1
source

This is a bitwise exclusive OR for two integers. http://bytes.com/topic/c/answers/726626-what-caret-qualifier

0
source

All Articles