Weird outcome

So I wondered if you could do cin>> var1, var2; and I made this little program. the only flaw is, it always says FALSE =S

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

using namespace std;


double var1, var2;
bool x;

int main ()
{
    cout<< boolalpha;

    cout<<"give first number";
    cin>> var1, var2;


    x = var1==var2;
    cout<< x ;

    return 0;
}


Is it actually even possible to cin>> var1, var2;

Thanks in advance,

Xander
cin >> var1 >> var2;
That's how you do it. The >> operator returns a pointer to the istream object on its left, in this case std::cin.
http://cplusplus.com/reference/iostream/istream/operator%3E%3E/

-Albatross
Last edited on
Thanks (again) Albatross!
Topic archived. No new replies allowed.