• <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++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            atoi函數(shù)源代碼

            Posted on 2010-09-06 13:13 Prayer 閱讀(7505) 評(píng)論(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博客,轉(zhuǎn)載請(qǐng)標(biāo)明出處:http://blog.csdn.net/udknight/archive/2007/10/22/1836799.aspx

            Feedback

            # re: atoi函數(shù)源代碼  回復(fù)  更多評(píng)論   

            2012-04-18 23:20 by 春秋十二月
            實(shí)現(xiàn)基本可以,但沒處理數(shù)據(jù)溢出和字符集的情況

            # re: atoi函數(shù)源代碼  回復(fù)  更多評(píng)論   

            2014-11-04 21:30 by 張瑞昌
            對(duì)啊,怎么源碼都沒處理溢出問題!
            色偷偷88欧美精品久久久 | 99久久精品国产一区二区蜜芽| 久久久久久亚洲AV无码专区 | 精品无码人妻久久久久久| 国产亚洲精午夜久久久久久| 2021国内精品久久久久久影院| 亚洲精品乱码久久久久久蜜桃不卡 | 久久涩综合| 久久Av无码精品人妻系列| 久久精品无码免费不卡| 久久久久久精品无码人妻| www亚洲欲色成人久久精品| 国产成人精品综合久久久久| 久久精品成人| 久久婷婷综合中文字幕| 亚洲伊人久久精品影院| 久久无码AV中文出轨人妻| 99久久免费国产精精品| 久久人妻无码中文字幕| 久久婷婷人人澡人人| 久久精品国产亚洲欧美| 亚洲国产一成人久久精品| 久久久久一本毛久久久| 久久久国产精品网站| 亚洲va久久久噜噜噜久久| 狠狠88综合久久久久综合网| 日本亚洲色大成网站WWW久久 | 99久久久国产精品免费无卡顿| 久久精品嫩草影院| 色婷婷综合久久久久中文 | 亚洲人成精品久久久久| 久久综合久久伊人| 久久久久人妻精品一区三寸蜜桃 | 久久久久AV综合网成人| 亚洲精品国产美女久久久| 久久亚洲AV成人无码| 久久精品综合网| 久久国产AVJUST麻豆| 久久成人小视频| 久久无码人妻一区二区三区| 人妻少妇久久中文字幕|