• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            笑看風云淡

            寵辱不驚,看庭前花開花落;去留無意,望天空云卷云舒
            posts - 96, comments - 48, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            C++語言小技巧

            Posted on 2007-08-31 16:13 天之驕子 閱讀(350) 評論(0)  編輯 收藏 引用

            isalnum(測試字符是否為英文或數字)
            相關函數
            isalpha,isdigit,islower,isupper
            表頭文件
            #include<ctype.h>
            定義函數
            int isalnum (int c)
            函數說明
            檢查參數c是否為英文字母或阿拉伯數字,在標準c中相當于使用“isalpha(c) || isdigit(c)”做測試。
            返回值
            若參數c為字母或數字,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /* 找出str 字符串中為英文字母或數字的字符*/
            #include < ctype.h>
            main()
            {
            char str[]=”123c@#FDsP[e?”;
            int i;
            for (i=0;str[i]!=0;i++ )
            if ( isalnum(str[i])) printf(“%c is an alphanumeric character\n”,str[i]);
            }
            執行
            1 is an apphabetic character
            2 is an apphabetic character
            3 is an apphabetic character
            c is an apphabetic character
            F is an apphabetic character
            D is an apphabetic character
            s is an apphabetic character
            P is an apphabetic character
            e is an apphabetic character
             



            isalpha (測試字符是否為英文字母)
            相關函數
            isalnum,islower,isupper
            表頭文件
            #include<ctype.h>
            定義函數
            int isalpha (int c)
            函數說明
            檢查參數c是否為英文字母,在標準c中相當于使用“isupper(c)||islower(c)”做測試。
            返回值
            若參數c為英文字母,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /* 找出str 字符串中為英文字母的字符*/
            #include <ctype.h>
            main()
            {
            char str[]=”123c@#FDsP[e?”;
            int i;
            for (i=0;str[i]!=0;i++)
            if(isalpha(str[i])) printf(“%c is an alphanumeric character\n”,str[i]);
            }
            執行
            c is an apphabetic character
            F is an apphabetic character
            D is an apphabetic character
            s is an apphabetic character
            P is an apphabetic character
            e is an apphabetic character
             



            isascii(測試字符是否為ASCII 碼字符)
            相關函數
            iscntrl
            表頭文件
            #include <ctype.h>
            定義函數
            int isascii(int c);
            函數說明
            檢查參數c是否為ASCII碼字符,也就是判斷c的范圍是否在0到127之間。
            返回值
            若參數c為ASCII碼字符,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /* 判斷int i是否具有對映的ASCII碼字符*/
            #include<ctype.h>
            main()
            {
            int i;
            for(i=125;i<130;i++)
            if(isascii(i))
            printf("%d is an ascii character:%c\n",i,i);
            else
            printf("%d is not an ascii character\n",i);
            }
            執行
            125 is an ascii character:}
            126 is an ascii character:~
            127 is an ascii character:
            128 is not an ascii character
            129 is not an ascii character
             



            iscntrl(測試字符是否為ASCII 碼的控制字符)
            相關函數
            isascii
            表頭文件
            #include <ctype.h>
            定義函數
            int iscntrl(int c);
            函數說明
            檢查參數c是否為ASCII控制碼,也就是判斷c的范圍是否在0到30之間。
            返回值
            若參數c為ASCII控制碼,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
             



            isdigit(測試字符是否為阿拉伯數字)
            相關函數
            isxdigit
            表頭文件
            #include<ctype.h>
            定義函數
            int isdigit(int c)
            函數說明
            檢查參數c是否為阿拉伯數字0到9。
            返回值
            若參數c為阿拉伯數字,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /* 找出str字符串中為阿拉伯數字的字符*/
            #include<ctype.h>
            main()
            {
            char str[]="123@#FDsP[e?";
            int i;
            for(i=0;str[i]!=0;i++)
            if(isdigit(str[i])) printf("%c is an digit character\n",str[i]);
            }
            執行
            1 is an digit character
            2 is an digit character
            3 is an digit character
             



            isgraphis(測試字符是否為可打印字符)
            相關函數
            isprint
            表頭文件
            #include <ctype.h>
            定義函數
            int isgraph (int c)
            函數說明
            檢查參數c是否為可打印字符,若c所對映的ASCII碼可打印,且非空格字符則返回TRUE。
            返回值
            若參數c為可打印字符,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /* 判斷str字符串中哪些為可打印字符*/
            #include<ctype.h>
            main()
            {
            char str[]="a5 @;";
            int i;
            for(i=0;str[i]!=0;i++)
            if(isgraph(str[i])) printf("str[%d] is printable character:%d\n",i,str[i]);
            }
            執行
            str[0] is printable character:a
            str[1] is printable character:5
            str[3] is printable character:@
            str[4] is printable character:;
             



            islower(測試字符是否為小寫字母)
            相關函數
            isalpha,isupper
            表頭文件
            #include<ctype.h>
            定義函數
            int islower(int c)
            函數說明
            檢查參數c是否為小寫英文字母。
            返回值
            若參數c為小寫英文字母,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            #include<ctype.h>
            main()
            {
            char str[]="123@#FDsP[e?";
            int i;
            for(i=0;str[i]!=0;i++)
            if(islower(str[i])) printf("%c is a lower-case character\n",str[i]);
            }
            執行
            c is a lower-case character
            s is a lower-case character
            e is a lower-case character
             



            isprint(測試字符是(否為可打印字符)
            相關函數
            isgraph
            表頭文件
            #include<ctype.h>
            定義函數
            int isprint(int c);
            函數說明
            檢查參數c是否為可打印字符,若c所對映的ASCII碼可打印,其中包含空格字符,則返回TRUE。
            返回值
            若參數c為可打印字符,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /* 判斷str字符串中哪些為可打印字符包含空格字符*/
            #include<ctype.h>
            main()
            {
            char str[]="a5 @;";
            int i;
            for(i=0;str[i]!=0;i++)
            if(isprint(str[i])) printf("str[%d] is printable character:%d\n",i,str[i]);
            }
            執行
            str[0] is printable character:a
            str[1] is printable character:5
            str[2] is printable character:
            str[3] is printable character:@
            str[4] is printable character:;
             



            isspace(測試字符是否為空格字符)
            相關函數
            isgraph
            表頭文件
            #include<ctype.h>
            定義函數
            int isspace(int c)
            函數說明
            檢查參數c是否為空格字符,也就是判斷是否為空格('')、定位字符('\t')、CR('\r')、換行('\n')、垂直定位字符('\v')或翻頁('\f')的情況。
            返回值
            若參數c為空格字符,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /*將字符串str[]中內含的空格字符找出,并顯示空格字符的ASCII碼*/
            #include <ctype.h>
            main()
            {
            char str="123c @# FD\tsP[e?\n";
            int i;
            for(i=0;str[i]!=0;i++)
            if(isspace(str[i]))
            printf("str[%d] is a white-space character:%d\n",i,str[i]);
            }
            執行
            str[4] is a white-space character:32
            str[7] is a white-space character:32
            str[10] is a white-space character:9 /* \t */
            str[16] is a white-space character:10 /* \t */
             



            ispunct(測試字符是否為標點符號或特殊符號)
            相關函數
            isspace,isdigit,isalpha
            表頭文件
            #inlude<ctype.h>
            定義函數
            int ispunct(int c)
            函數說明
            檢查參數c是否為標點符號或特殊符號。返回TRUE也就是代表參數c為非空格、非數字和非英文字母。
            返回值
            v若參數c為標點符號或特殊符號,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /*列出字符串str中的標點符號或特殊符號*/
            #include <ctype.h>
            main()
            {
            char str[]="123c@ #FDsP[e?";
            int i;
            for(i=0;str[i]!=0;i++)
            if(ispunct(str[i])) printf("%c\n",str[i]);
            }
            執行
            v
            @#[?
             



            isupper(測試字符是否為大寫英文字母)
            相關函數
            isalpha,islower
            表頭文件
            #include<ctype.h>
            定義函數
            int isupper(int c)
            函數說明
            檢查參數c是否為大寫英文字母。
            返回值
            若參數c為大寫英文字母,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /*找出字符串str中為大寫英文字母的字符*/
            #include <ctype.h>
            main()
            {
            char str[]="123c@#FDsP[e?";
            int i;
            for(i=0;str[i]!=0;i++)
            if(isupper(str[i])) printf("%c is an uppercase character\n",str[i]);
            }
            執行
            F is an uppercase character
            D is an uppercase character
            P is an uppercase character
             



            isxdigit(測試字符是否為16進制數字)
            相關函數
            isalnum,isdigit
            表頭文件
            #include<ctype.h>
            定義函數
            int isxdigit (int c)
            函數說明
            檢查參數c是否為16進制數字,只要c為下列其中一個情況則返回TRUE。16進制數字:0123456789ABCDEF。
            返回值
            若參數c為16進制數字,則返回TRUE,否則返回NULL(0)。
            附加說明
            此為宏定義,非真正函數。
            范例
            /*找出字符串str中為十六進制數字的字符*/
            #include <ctype.h>
            main()
            {
            char str[]="123c@#FDsP[e?";
            int i;
            for(i=0;str[i]!=0;i++)
            if(isxdigit(str[i])) printf("%c is a hexadecimal digits\n",str[i]);
            }
            執行
            1 is a hexadecimal digits
            2 is a hexadecimal digits
            3 is a hexadecimal digits
            c is a hexadecimal digits
            F is a hexadecimal digits
            D is a hexadecimal digits
            e is a hexadecimal digits

            久久A级毛片免费观看| 久久这里都是精品| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 亚洲一区精品伊人久久伊人| 国产99久久久国产精品小说| 亚洲综合日韩久久成人AV| 色欲久久久天天天综合网精品| 久久99精品久久久久久齐齐| 亚洲精品国产综合久久一线| 国产成人精品综合久久久| 国产美女久久久| 日日狠狠久久偷偷色综合96蜜桃| 婷婷伊人久久大香线蕉AV| 99久久综合狠狠综合久久| 久久精品www人人爽人人| 久久精品无码一区二区三区免费| 亚洲国产精品久久66| 亚洲伊人久久大香线蕉综合图片| 成人国内精品久久久久一区| 亚洲狠狠久久综合一区77777| 亚洲国产精品久久久久婷婷老年| 久久国产精品国语对白| 久久精品中文字幕无码绿巨人| 欧美色综合久久久久久| 69SEX久久精品国产麻豆| 久久人爽人人爽人人片AV| 久久九九免费高清视频| 97久久精品人妻人人搡人人玩| 久久国产劲爆AV内射—百度| 久久无码专区国产精品发布| 国产精品综合久久第一页 | 国产真实乱对白精彩久久| 久久精品一本到99热免费| 久久天天躁夜夜躁狠狠| 亚洲欧美另类日本久久国产真实乱对白 | 久久久久久久97| 欧美亚洲国产精品久久高清| 久久九九免费高清视频 | 99久久精品免费看国产一区二区三区 | 久久99精品久久久久久hb无码| 亚洲国产精品无码久久98|