2

That is the data is already provided by another program, or user must type it manually. I mean these two states:

dir /b /s *.* | myprogram

and

myprogram

In second case the program would be waiting for user input. Is there a way to prevent that ?

Steve Jessop
  • 273,490
  • 39
  • 460
  • 699
rsk82
  • 28,217
  • 50
  • 150
  • 240

2 Answers2

6

POSIX has isatty(), whereas Visual C++ has _isatty(), both of which will return true if a file descriptor is a terminal or command line, e.g. isatty(fileno(stdin)).

smocking
  • 3,689
  • 18
  • 22
3

Yes. Use GetStdHandle to get the STD_INPUT_HANDLE and then check that the handle is of the type FILE_TYPE_PIPE in the first case or FILE_TYPE_CHAR in the second case by calling GetFileType on it.

Yakov Galka
  • 70,775
  • 16
  • 139
  • 220