xoring values from vector?

Ok so im trying to xor values from the vector but im not sure how to go about doing it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> vars;

    int num;
    int result;
    int number = 1;

    while(num != -1)
    {
        cout << "enter value #" << number++ << endl;
        cin >> num;
        vars.push_back(num);
    }

    cin.get();
    return 0;
}
What are you supposed to XOR? XOR takes two operands. You're implying the entries in the vector are one of the two numbers. What is the other?

BTW, at line 14 num is uninitialized. You could skip the whole loop if memory happens to contain -1.
xor needs another value after the operator:

34 ^ 89

cout << (vars.at(x) ^ 12) << endl;
Topic archived. No new replies allowed.