A while ago, I asked how I could determine, from a C++ program running on Windows, whether stdout was pointing to the console. I received a useful answer: GetConsoleMode().
UPDATE: To be specific, this expression evaluates as true if stdout points to the console:
GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &temp)
Now I'm trying to solve the same problem on Mac. Is there a similar function that I can call from Mac OS X to determine whether stdout is pointing to the console?
UPDATE: People have suggested using the function isatty(), which takes a file descriptor. In the Windows case, that descriptor was obtained by calling GetStdHandle(STD_OUTPUT_HANDLE). I will check out whether I can call isatty(fileno(stdout))
, as suggested.