• <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 閱讀(7506) 評論(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中文字幕无码久久久妻妇 | 国产精品丝袜久久久久久不卡| 国产精品gz久久久| 亚洲国产精品久久电影欧美| 久久美女人爽女人爽| 精品国产乱码久久久久软件| 久久99国产亚洲高清观看首页| 色综合久久久久综合99| 精品久久一区二区三区| 久久久久波多野结衣高潮| 91久久香蕉国产熟女线看| 久久精品一本到99热免费| 久久高潮一级毛片免费| 久久国产色AV免费观看| 99久久国产宗和精品1上映| 久久亚洲精品视频| 久久久久久久久久久久中文字幕| 一本色道久久综合狠狠躁篇 | 久久99精品久久久久久久不卡| 久久综合精品国产一区二区三区| 97久久天天综合色天天综合色hd | 久久伊人中文无码| 国产香蕉97碰碰久久人人| 国内精品人妻无码久久久影院| 国产香蕉久久精品综合网| 久久精品国产99久久香蕉| 久久夜色精品国产亚洲| 久久精品国产亚洲网站| 99久久免费国产精精品| 日本道色综合久久影院| 久久亚洲私人国产精品| 狼狼综合久久久久综合网| 国产精品99久久99久久久| 狠狠色丁香婷婷久久综合不卡| 99精品国产在热久久无毒不卡| 69国产成人综合久久精品| 亚洲精品高清国产一久久| 久久男人中文字幕资源站| 一本色道久久88综合日韩精品 | 91精品国产91久久久久久蜜臀|