Is there a way to determine in C ++ whether the Mac is stdout pointing to the console?

Some time ago, I asked how I could determine, from a C ++ program running on Windows , whether stdout was pointing to the console. I got a useful answer: GetConsoleMode ().

UPDATE: to be specific, this expression evaluates to true if stdout points to the console:

GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &temp) 

Now I am trying to solve the same problem on Mac . Is there a similar function that I can call from Mac OS X to determine if stdout points to the console?

UPDATE: people suggested using the isatty () function, which takes a file descriptor. For Windows, this handle was obtained by calling GetStdHandle (STD_OUTPUT_HANDLE). I will check if I can name isatty(fileno(stdout)) as suggested.

+6
source share

All Articles