How can I xor two data segments pointed by pointers?
I've tried this, one based on a similar solution on stackoverflow, but the output is not what I expected.
Here is the code:
void printXor(){
int j;
char* c = strdup("hey");
for(j = 0; j < strlen(c); j++){
c[j] ^= c[j];
}
printf("%d\n", *(int*)(c));
}
But the output is: 7955712
. Shouldn't the output be 0? I'm xoring "hey" over "hey" and its value in int is 0 right?