• <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 閱讀(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博客,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/udknight/archive/2007/10/22/1836799.aspx

            Feedback

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

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

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

            2014-11-04 21:30 by 張瑞昌
            對啊,怎么源碼都沒處理溢出問題!
            免费精品久久天干天干| 亚洲国产一成久久精品国产成人综合| 久久久久久国产精品无码下载 | 国内精品人妻无码久久久影院| 97久久超碰国产精品旧版| 久久精品国产色蜜蜜麻豆| A级毛片无码久久精品免费| 久久国产精品成人免费| 少妇无套内谢久久久久| 久久精品视频网| 精品久久久久久国产| 久久夜色tv网站| 久久精品国产亚洲Aⅴ香蕉| 久久狠狠一本精品综合网| 97精品国产97久久久久久免费| 国产精品欧美久久久天天影视| 亚洲欧洲精品成人久久曰影片 | 国产亚洲精品久久久久秋霞| 久久精品一区二区| 久久无码人妻一区二区三区午夜| 久久精品女人天堂AV麻| 国产精品久久一区二区三区 | 久久久久久人妻无码| 久久久久99精品成人片三人毛片| 久久久精品人妻一区二区三区蜜桃| 久久有码中文字幕| 7国产欧美日韩综合天堂中文久久久久| 久久人人爽人人爽人人片AV不| 国产无套内射久久久国产| 久久精品一本到99热免费| 欧美日韩久久中文字幕| 亚洲美日韩Av中文字幕无码久久久妻妇 | 久久亚洲国产精品成人AV秋霞| 草草久久久无码国产专区| 91久久精品91久久性色| 东京热TOKYO综合久久精品| 久久国产乱子伦免费精品| 国产成人久久精品一区二区三区| 久久人妻少妇嫩草AV无码专区| 一本色道久久99一综合| 欧美黑人激情性久久|