char* rev(char* str){
int end= strlen(str)-1;
int start = 0;
while( start<end )
{
str[start] ^= str[end];
str[end] ^= str[start];
str[start]^= str[end];
++start;
--end;
}
return str;
}
XOR (Exclusive OR) table |
0 XOR 0 = 0 |
0 XOR 1 = 1 |
1 XOR 0 = 1 |
1 XOR 1 = 0 |
First operation: | x1 = x1 XOR x2 | ||
x1: | 1 | 0 | 0 |
x2: | 1 | 1 | 1 |
New x1: | 0 | 1 | 1 |
Second operation | x2 = x2 XOR x1 | ||
x1: | 0 | 1 | 1 |
x2: | 1 | 1 | 1 |
New x2: | 1 | 0 | 0 |
Third operation: | x1 = x1 XOR x2 | ||
x1: | 0 | 1 | 1 |
x2: | 1 | 0 | 0 |
New x1: | 1 | 1 | 1 |