• <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>

            Prayer

            在一般中尋求卓越
            posts - 1256, comments - 190, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            atoi函數源代碼

            Posted on 2010-09-06 13:13 Prayer 閱讀(7499) 評論(2)  編輯 收藏 引用 所屬分類: C/C++

            isspace(int x)
            {
             if(x==' '||x=='\t'||x=='\n'||x=='\f'||x=='\b'||x=='\r')
              return 1;
             else 
              return 0;
            }
            isdigit(int x)
            {
             if(x<='9'&&x>='0')        
              return 1;x`
             else
              return 0;

            }
            int atoi(const char *nptr)
            {
                    int c;              /* current char */
                    int total;         /* current total */
                    int sign;           /* if '-', then negative, otherwise positive */

                    /* skip whitespace */
                    while ( isspace((int)(unsigned char)*nptr) )
                        ++nptr;

                    c = (int)(unsigned char)*nptr++;
                    sign = c;           /* save sign indication */
                    if (c == '-' || c == '+')
                        c = (int)(unsigned char)*nptr++;    /* skip sign */

                    total = 0;

                    while (isdigit(c)) {
                        total = 10 * total + (c - '0');     /* accumulate digit */
                        c = (int)(unsigned char)*nptr++;    /* get next char */
                    }

                    if (sign == '-')
                        return -total;
                    else
                        return total;   /* return result, negated if necessary */
            }

             

            本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/udknight/archive/2007/10/22/1836799.aspx

            Feedback

            # re: atoi函數源代碼  回復  更多評論   

            2012-04-18 23:20 by 春秋十二月
            實現基本可以,但沒處理數據溢出和字符集的情況

            # re: atoi函數源代碼  回復  更多評論   

            2014-11-04 21:30 by 張瑞昌
            對啊,怎么源碼都沒處理溢出問題!
            久久久艹| 国内精品久久久久久久影视麻豆| 爱做久久久久久| 久久天天日天天操综合伊人av| 久久精品国产亚洲7777| 国产综合免费精品久久久| 久久996热精品xxxx| 色诱久久av| 日本免费一区二区久久人人澡| 亚洲午夜久久久| 九九久久99综合一区二区| 久久人人爽人人爽人人片AV不| 久久精品国产99久久无毒不卡| 亚洲另类欧美综合久久图片区| 一本久久知道综合久久| 99久久国产亚洲综合精品| 一级做a爱片久久毛片| 精品综合久久久久久888蜜芽| 亚洲天堂久久久| 久久成人精品视频| 99久久这里只精品国产免费| 亚洲欧美日韩精品久久| 久久精品视频一| 久久久久国产精品三级网| 久久久无码精品亚洲日韩按摩 | 91久久九九无码成人网站| 日日狠狠久久偷偷色综合免费| 久久婷婷五月综合97色| 亚洲国产精品无码久久一区二区| 久久精品国产亚洲av麻豆蜜芽| 香蕉久久夜色精品国产小说| 久久亚洲日韩精品一区二区三区| 午夜精品久久久久9999高清| 一本大道加勒比久久综合| 久久综合给合久久狠狠狠97色| 久久人做人爽一区二区三区| 国产三级观看久久| 国产精品狼人久久久久影院| 色综合久久88色综合天天| 99久久精品国产高清一区二区 | 国产精品久久久久jk制服|