How to know if std::cin is from redirect?

Viewed 207

Let's say I have a small program like:

int main() 
{
    cout << "Please enter the param >" << endl; // <-- Print only if input from console
    std::string param;
    cin >> param;
    //Doing some calculations...
    cout << "result is..."
} 

I want to print the request for the parameter only if the input is from the console, but if the program was started with redirect myApp.exe < textfile.txt then I see no point in printing it.

How can I achieve this behavior?

Edit - I'm working on windows.

2 Answers
Related