Hey
I'm trying to make a simple calculator, at this point I can't even get the input right.
I know my code is kinda ugly but afaik it should work.
int _tmain(int argc, _TCHAR* argv[])
{
int get1=0, get2=0;
cout << "Binary operation" << endl;
//cin.get();
do
{
if(get1==0)cout << "Enter first operand (integer): >";
if (!(cin >> get1) && get1==0) {
cout << "Did you even try?" << endl;
cin.clear();
cin.ignore(1000, '\n');
}
else {
if(get2==0)cout << "Enter second operand (integer): >";
if (!(cin >> get2)){
cout << "Cmon! You can do it!" << endl;
cin.clear();
cin.ignore(1000, '\n');
}
else cout << "Good boy! Press ENTER to continue" << endl;
}
} while (get1==0 || get2==0);
return 0;
}
This is how the console responds:
Why do I get an blanc line on the end instead of the line "Enter second operand (integer): >" ?
What should I change?
Thanks in advance!