#include <iostream>
#include <stdexcept>
using namespace std;
int main(void) {
int a;
std::cout << "Please enter an integer: " << std::endl;
while (std::cin >> a) {
try {
if (a > 0) {
std::cout << a << "Your enter was fucking correct." << std::endl;
std::cout << "Please enter an integer: " << std::endl;
}
else
throw runtime_error("It is not
even an integer.");
}
catch (runtime_error err) {
std::cout << err.what()
<<
"\nTry again? Enter /d
y or' /" << std::endl;
char c;
std::cin >> c;
if (std::cin && c == 'n')
break;
std::cout << "Please enter an integer: " << std::endl;
}
}
return 0;
}
|
"std::cin" in "if (std::cin && c == 'n')" is the part that I don't understand.
Before that, c has been already given a value.
I deleted "std::cin" part and the program works the same.
What is the value of "std::cin" here?
I deleted "std::cin" part and the program works the same.
What is the value of "std::cin" here?
What does "std::cin" mean in this if condition?
No comments:
Post a Comment