0
Bitwise XOR using two strings in C
rem and key are char array containing 1011 and 1101 respectively. for(j=0;j<length;j++) Â Â { rem[j]=((rem[j])^(key[j])); } After execution of the above code using XOR, infinite loop occurs for(j=0;j<length;j++) { rem[j]=( (rem[j])^(key[j]) )+'0'; } But if I add '0' it gives me the correct output So why does the code work with the +'0' ?
1 Answer
0
Maybe the XOR operation is returning an int value which is making the comparison invalid in the first loop
To avoid this in your second loop the int value is converted to s char by adding character zero
Maybe you can look up to some documentation on coversion between char and int ... And try to print the value of XOR operation to see what it is actually returning...