當前位置:編程學習大全網 - 網站源碼 - C++ 數據類型轉換問題: 如何把主函數中錄入的char * argv 類型數據轉換成64位無符號長整形

C++ 數據類型轉換問題: 如何把主函數中錄入的char * argv 類型數據轉換成64位無符號長整形

對,如樓上所述。

另外,給妳個修改過的源碼,相當於_atoi64,返回的數為long long 類型,可以支持比4294967295 大的數字的處理。

long long MY_atol( const char *nptr )

{

int c; /* current char */

long long 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 */

}

  • 上一篇:請問高手能否把下面通達信的主要指標換成選股公式來挑選當天有黃金k線的股票?
  • 下一篇:c語言中strlen()怎麽用
  • copyright 2024編程學習大全網