Check output device is a terminal: Difference between revisions
Content added Content deleted
No edit summary |
(added solution for c++) |
||
Line 65: | Line 65: | ||
stdout is not tty |
stdout is not tty |
||
</pre> |
</pre> |
||
=={{header|C++}}== |
|||
{{trans|C}} |
|||
<lang cpp>#if _WIN32 |
|||
#include <io.h> |
|||
#define ISATTY _isatty |
|||
#define FILENO _fileno |
|||
#else |
|||
#include <unistd.h> |
|||
#define ISATTY isatty |
|||
#define FILENO fileno |
|||
#endif |
|||
#include <iostream> |
|||
int main() { |
|||
if (ISATTY(FILENO(stdout))) { |
|||
std::cout << "stdout is a tty\n"; |
|||
} else { |
|||
std::cout << "stdout is not a tty\n"; |
|||
} |
|||
return 0; |
|||
}</lang> |
|||
=={{header|C#|C sharp}}== |
=={{header|C#|C sharp}}== |