• <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 張瑞昌
            對啊,怎么源碼都沒處理溢出問題!
            久久久久亚洲精品中文字幕 | 思思久久99热只有频精品66| 国产2021久久精品| 人人狠狠综合久久亚洲高清| 久久精品国产乱子伦| 99久久精品国产综合一区| 久久久久99这里有精品10| 久久综合噜噜激激的五月天| 亚洲国产精品久久久久久| 亚洲日本va午夜中文字幕久久| 久久久久久久久无码精品亚洲日韩| 99久久婷婷国产综合精品草原| 四虎国产精品成人免费久久| 99久久精品国产一区二区| 久久亚洲精品无码aⅴ大香| 伊人色综合久久天天| 亚洲中文字幕无码久久2017| 国产精品久久久久乳精品爆| 99久久国产精品免费一区二区 | 久久亚洲AV无码精品色午夜麻豆 | 色妞色综合久久夜夜| 久久久WWW成人| 精品综合久久久久久97超人| 色妞色综合久久夜夜| 国产精品免费看久久久香蕉| 99久久久国产精品免费无卡顿| 亚洲精品成人网久久久久久| 国产精品无码久久久久| 欧美伊香蕉久久综合类网站| 69SEX久久精品国产麻豆| 久久亚洲熟女cc98cm| 日韩十八禁一区二区久久| 亚洲国产成人久久精品影视| 国产精品久久99| 久久国产精品-久久精品| 99久久中文字幕| 久久99毛片免费观看不卡| 天天爽天天爽天天片a久久网| 久久国产高清字幕中文| 国产精品午夜久久| 香蕉99久久国产综合精品宅男自|