• <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 天之驕子 閱讀(353) 評論(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

            久久精品人人做人人爽电影 | 久久久无码精品亚洲日韩蜜臀浪潮 | 少妇久久久久久久久久| 久久夜色精品国产亚洲| 亚洲AV日韩精品久久久久久| 国产91色综合久久免费| 久久国产视屏| 久久天堂AV综合合色蜜桃网| 国产A级毛片久久久精品毛片| 久久无码高潮喷水| 国产高潮国产高潮久久久91| 伊人久久大香线蕉av不卡| 久久最近最新中文字幕大全| 中文字幕热久久久久久久| 国产成人综合久久精品尤物| 久久久久久久久久久久中文字幕 | 秋霞久久国产精品电影院| 久久婷婷五月综合97色直播| 国产精品久久久久久| 99久久香蕉国产线看观香| 日本精品久久久久中文字幕| 久久国产精品99国产精| 久久综合久久鬼色| 国产午夜精品理论片久久| 久久国产精品99精品国产987| 亚洲AV无码久久| 漂亮人妻被中出中文字幕久久| 狠狠精品干练久久久无码中文字幕| 精品蜜臀久久久久99网站| 久久99精品久久久大学生| 亚洲欧洲精品成人久久奇米网| 色综合久久最新中文字幕| 狠狠狠色丁香婷婷综合久久俺| 久久精品国产亚洲av影院| 久久久久久亚洲AV无码专区| 欧洲精品久久久av无码电影| 亚洲人成精品久久久久| 97久久国产露脸精品国产| 麻豆精品久久久久久久99蜜桃| 欧美一区二区久久精品| 久久久综合香蕉尹人综合网|