Ok, that is your opportunity to join the white side of the force and stop using using namespace std;
The following example works fine for int
inputs:
#include <iostream>
int main ()
{
int cin;
std::cin >> cin;
std::cout << "cin: " << cin;
return 0;
}
Why? In your example your local name int cin
will take preference over cin
from std
and cause your program have UB using an int
variable without initializing.
And a good advise, but offtopic could be to test the result of std::cin::operator >>
with the failbit like this link