• <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 張瑞昌
            對啊,怎么源碼都沒處理溢出問題!
            狠狠色丁香久久综合婷婷| 国内精品久久久久久中文字幕| 久久久久国产精品嫩草影院| 久久乐国产精品亚洲综合| 日韩va亚洲va欧美va久久| 亚洲综合伊人久久综合| 浪潮AV色综合久久天堂| 国内精品久久久久久久久| 一级做a爰片久久毛片免费陪 | 久久综合伊人77777麻豆| 欧美伊人久久大香线蕉综合| 国产成人精品综合久久久久| 久久精品9988| 国内高清久久久久久| 色综合色天天久久婷婷基地| 少妇熟女久久综合网色欲| 国产精品嫩草影院久久| 久久丫精品国产亚洲av| 亚洲人成无码网站久久99热国产| 久久精品国产99久久久| 久久精品极品盛宴观看| 久久99热只有频精品8| 久久亚洲AV成人无码| 国产精品99久久久久久www| 久久综合九色综合网站| 四虎国产精品成人免费久久| 999久久久国产精品| 精品综合久久久久久97超人 | 国产91色综合久久免费分享| 国产99久久久国产精品小说| 精品人妻伦九区久久AAA片69| 国产V亚洲V天堂无码久久久| 色综合久久中文字幕无码| 久久91精品国产91| 无码人妻久久一区二区三区蜜桃| 久久久久99精品成人片牛牛影视| 国产 亚洲 欧美 另类 久久| 国产免费福利体检区久久| 国产免费久久精品丫丫| 久久精品这里只有精99品| 久久人人爽人人爽AV片|