_isatty_isatty
ファイル記述子が文字デバイスに関連付けられているかどうかを判定します。Determines whether a file descriptor is associated with a character device.
構文Syntax
int _isatty( int fd );
パラメーターParameters
スクリプターfd
調べるデバイスを参照するファイル記述子。File descriptor that refers to the device to be tested.
戻り値Return Value
記述子が文字デバイスに関連付けられている場合、 _isatty は0以外の値を返します。_isatty returns a nonzero value if the descriptor is associated with a character device. それ以外の場合、 _isatty は0を返します。Otherwise, _isatty returns 0.
解説Remarks
_Isatty 関数は、 fd がキャラクターデバイス (端末、コンソール、プリンター、またはシリアルポート) に関連付けられているかどうかを判断します。The _isatty function determines whether fd is associated with a character device (a terminal, console, printer, or serial port).
この関数は、 fd パラメーターを検証します。This function validates the fd parameter. Fd が無効なファイルポインターの場合は、「パラメーターの検証」で説明されているように、無効なパラメーターハンドラーが呼び出されます。If fd is a bad file pointer, the invalid parameter handler is invoked, as described in Parameter Validation. 実行の継続が許可された場合、この関数は0を返し、 errno を EBADF に設定します。If execution is allowed to continue, the function returns 0 and sets errno to EBADF.
既定では、この関数のグローバル状態はアプリケーションにスコープが設定されています。By default, this function's global state is scoped to the application. これを変更するには、「 CRT でのグローバル状態」を参照してください。To change this, see Global state in the CRT.
必要条件Requirements
ルーチンによって返される値Routine | 必須ヘッダーRequired header |
---|---|
_isatty_isatty | <io.h> |
互換性について詳しくは、「 Compatibility」をご覧ください。For more compatibility information, see Compatibility.
ライブラリLibraries
C ランタイム ライブラリのすべてのバージョン。All versions of the C run-time libraries.
例Example
// 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");
}
出力例Sample Output
stdout has not been redirected to a file