C 教程
C 庫函數(shù) void iscntrl(int c) 檢查所傳的字符是否是控制字符。
根據(jù)標(biāo)準(zhǔn) ASCII 字符集,控制字符的 ASCII 編碼介于 0x00 (NUL) 和 0x1f (US) 之間,以及 0x7f (DEL),某些平臺(tái)的特定編譯器實(shí)現(xiàn)還可以在擴(kuò)展字符集(0x7f 以上)中定義額外的控制字符。
下面是 iscntrl() 函數(shù)的聲明。
int iscntrl(int c);
如果 c 是一個(gè)控制字符,則該函數(shù)返回非零值,否則返回 0。
下面的實(shí)例演示了 iscntrl() 函數(shù)的用法。
#include <stdio.h> #include <ctype.h> int main () { int i = 0, j = 0; char str1[] = "all a about t programming"; char str2[] = "Runoob n tutorials"; /* 輸出字符串直到控制字符 a */ while( !iscntrl(str1[i]) ) { putchar(str1[i]); i++; } /* 輸出字符串直到控制字符 n */ while( !iscntrl(str2[j]) ) { putchar(str2[j]); j++; } return(0); }
讓我們編譯并運(yùn)行上面的程序,這將產(chǎn)生以下結(jié)果:
all Runoob其他擴(kuò)展