isatty 判斷裝置型別

2021-09-01 07:55:52 字數 510 閱讀 6804

isatty  判斷裝置型別

用  法: int isatty(int handle);  

乙個常見的用法是用來判斷當前命令是否使用了沒有標準的輸出和輸入

#include #include #include int main()else

if(!isatty (stdin_fileno))else

}

# ./test 

is not stdout_fileno

is not stdin_fileno

沒有標準的輸出和有標準輸入

# cat aa | ./test

is not stdout_fileno

is stdin_fileno

有標準的輸出和沒有標準輸入

# ./test >bb

# cat bb

is stdout_fileno

is not stdin_fileno

判斷當前裝置的型別 名

1。新增標頭檔案 import import import 2。新增 struct utsname systeminfo uname systeminfo nsstring machinename nsstring stringwithcstring systeminfo.machine encod...

更優雅地判斷iOS裝置型別

隨著iphonex的發布,導航欄高度在iphone中也不再是乙個64的常量了。因此,很多地方需要針對齊劉海的導航欄高度做適配,目前網上很多關於判斷是否為iphonex,使用了螢幕寬高來比較或者utsname的machine來判斷。這兩個方法都有一些缺點,使用寬高不夠優雅,以後可能出現相同寬高的螢幕,...

iOS 判斷裝置型別 第一響應者

加班解決本周五品質檢測的問題中,遇到這樣乙個問題,當我用4s模擬器跑的時候,鍵盤會擋住我的輸入框,所以相應處理是要把view上移,但是其他裝置,比如 5s 6s 螢幕比較大的裝置,就不會被遮擋住輸入框,此時不用理會,要解決的僅僅是4或4s裝置。我在pch檔案裡,做了相應的巨集定義,主要以螢幕寬度來判...