2020-04-18

What does the first criterion mean in if (std: :cin && c == 'n') for C++?



#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? 

What does "std::cin" mean in this if condition?

No comments:

How to Add a Directory to PATH in Linux

 https://linuxize.com/post/how-to-add-directory-to-path-in-linux/ When you type a command on the command line, you’re basically telling the ...