Output XOR operation

closed account (4ET0pfjN)
I found this online to get an idea how to build an encryption function but why can't I output each operation as in e.g.

cout << string[0]^key[0];

Here is the simple encryption program:
======================================
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream.h>
int main()
{
  char string[11]="A nice cat";
  char key[11]="ABCDEFGHIJ";
  for(int x=0; x<10; x++)
  {
    string[x]=string[x]^key[x];
    cout<<string[x];
  }
  return 0;
}
I think ^ has lower precedence than <<. Try cout << (string[0]^key[0]);
closed account (4ET0pfjN)
Ok, now it's outputting, thanks for that. So I got:

65

but is that correct? (using: cout << (string[0]^key[0]); on one line outside the for loop.
It's correct if it's after the for loop. (string gets changed in the for loop, remember?)
Topic archived. No new replies allowed.