首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

isatty 判断装置类型

2012-09-15 
isatty判断设备类型?isatty ?判断设备类型用??法: int isatty(int handle) ?一个常见的用法是用来判断当

isatty 判断设备类型

?isatty ?判断设备类型

用??法: int isatty(int handle); ?

一个常见的用法是用来判断当前命令是否使用了没有标准的输出和输入

?

#include <stdio.h>  #include <unistd.h>#include <stdlib.h>int main(){    if (!isatty (STDOUT_FILENO)){        printf("is STDOUT_FILENO\n");    }else{        printf("is not STDOUT_FILENO\n");    }    if(!isatty (STDIN_FILENO)){        printf("is  STDIN_FILENO");    }else{        printf("is not STDIN_FILENO");    }}
# ./test is not STDOUT_FILENOis not STDIN_FILENO没有标准的输出和有标准输入# cat aa | ./test                       is not STDOUT_FILENOis  STDIN_FILENO有标准的输出和没有标准输入# ./test >bb# cat bbis STDOUT_FILENOis not STDIN_FILENO

?

?

热点排行