zoukankan      html  css  js  c++  java
  • C 标准库

    iscntrl

    int iscntrl ( int c );
    
    • Check if character is a control character
    • 检查给定字符是否为控制字符,即编码 0x00-0x1F 及 0x7F 。

    若 c 的值不能表示为 unsigned char 且不等于 EOF ,则行为未定义。

    Parameters

    c

    • Character to be checked, casted as an int, or EOF.
    • c - 要分类的字符

    Return Value

    • A value different from zero (i.e., true) if indeed c is a control character. Zero (i.e., false) otherwise.
    • 若字符为控制字符则为非零,否则为零。

    Example

    //
    // Created by zhangrongxiang on 2018/2/1 15:14
    // File iscntrl
    //
    
    #include <stdio.h>
    #include <ctype.h>
    #include <locale.h>
    
    int main() {
        unsigned char c = 'x94'; // ISO-8859-1 的控制码 CCH
        printf("In the default C locale, \x94 is %sa control character
    ",
               iscntrl(c) ? "" : "not ");
        //In the default C locale, x94 is not a control character
        setlocale(LC_ALL, "en_GB.iso88591");
        printf("In ISO-8859-1 locale, \x94 is %sa control character
    ",
               iscntrl(c) ? "" : "not ");
    
        int i = 0;
        char str[] = "first line 
     second line 
    ";
        while (!iscntrl(str[i])) {
            putchar(str[i]);
            i++;
        }
        //first line
        return 0;
    }
    
    
    ## 文章参考 - -
  • 相关阅读:
    构建之法阅读笔记04
    构建之法阅读笔记03
    第十二周学习进度情况
    课堂练习-找水王
    第十一周学习进度情况
    第十周学习进度情况
    课后作业:寻找水王
    《人月神话》阅读笔记01
    学习进度条
    学习进度条
  • 原文地址:https://www.cnblogs.com/zhangrxiang/p/8399247.html
Copyright © 2011-2022 走看看