I have an issue with behavior of "cin" (I do not understand). My IDE is Netbeans under Windows OS (with Cygwin).
Here's a code example:
int main()
{
int temp = -1;
std::cin >> temp; // here user enters string of characters (string) or a single character
if (temp == 0)
std::cout << "temp = " << temp << ".\n";
if (temp == -1)
std::cout << "temp = " << temp << ".\n";
return 0;
}
This code shows message temp = 0 if I enter some sort of a character/string of characters. It's like there is conversion of char
to int
and conversion always ending by value 0.
Thank you if you can explain this behavior.