• <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 張瑞昌
            對啊,怎么源碼都沒處理溢出問題!
            久久精品国产久精国产一老狼| 欧美久久一区二区三区| 亚洲人成伊人成综合网久久久| 久久综合亚洲欧美成人| 99久久精品费精品国产| 久久久久亚洲AV无码专区首JN | 午夜不卡久久精品无码免费| 波多野结衣中文字幕久久| 久久99精品久久久久久秒播| 少妇熟女久久综合网色欲| 国产精品久久久久久影院| 欧美午夜A∨大片久久| 久久国产精品无码一区二区三区| 久久久久无码国产精品不卡| 国产成人久久精品区一区二区| 亚洲а∨天堂久久精品| 人人狠狠综合久久亚洲婷婷| 2021国内久久精品| 精品久久久久久无码免费| 精品熟女少妇a∨免费久久| 久久99九九国产免费看小说| 久久国产美女免费观看精品 | 亚洲午夜久久久影院伊人| 久久久精品人妻无码专区不卡| 久久精品国产亚洲77777| 香蕉久久av一区二区三区| 久久91精品国产91久| 亚洲国产日韩欧美综合久久| 久久久久国产精品三级网| 久久久青草久久久青草| 国产成人久久精品一区二区三区| 亚洲精品乱码久久久久久 | 99久久免费国产精品热| 新狼窝色AV性久久久久久| 久久夜色精品国产噜噜麻豆| 亚洲精品国产字幕久久不卡| 亚洲AV日韩AV永久无码久久| 亚洲国产欧美国产综合久久| 无码人妻少妇久久中文字幕蜜桃 | 青青草国产精品久久久久| 97久久精品人人澡人人爽|