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 ?
POSIX具有isatty()
,而Visual C ++具有_isatty()
,如果文件描述符是终端或命令行,则两者都将返回true,例如isatty(fileno(stdin))
。
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.