_isatty
确定文件是否描述符与字符设备。
int _isatty( int fd );
参数
- fd
引用计算机上的文件说明符将测试。
返回值
如果描述符与字符设备,_isatty 返回一个非零值。 否则,_isatty 返回 0。
备注
_isatty 函数确定 fd 是否与字符设备 (最终、控件、台打印机或串行端口)。
此功能验证 fd 参数。 如果 fd 是一个坏文件指针,无效参数调用处理程序,如 参数验证所述。 如果执行允许继续,该函数返回 0 并将 errno 到 EBADF。
要求
实例 |
必需的标头 |
---|---|
_isatty |
<io.h> |
有关更多兼容性信息,请参见中介绍的 兼容性。
库
C 运行库的所有版本。
示例
// crt_isatty.c
/* This program checks to see whether
* stdout has been redirected to a file.
*/
#include <stdio.h>
#include <io.h>
int main( void )
{
if( _isatty( _fileno( stdout ) ) )
printf( "stdout has not been redirected to a file\n" );
else
printf( "stdout has been redirected to a file\n");
}
示例输出
stdout has not been redirected to a file