#include
#include
#include
#include
using namespace std;
int main(int argc, char **argv)
{
if (argc < 2)
{
cerr<
return -1;
}
cout<
unsigned long long ullNum1 = 0, ullNum2=0, ullNum3=0, ullNum4=0;
ullNum1 = atoi(argv[1]);
ullNum2 = atol(argv[1]);
ullNum3 = atoll(argv[1]);
ullNum4 = strtoull(argv[1], NULL, 10);
cout<
cout<
cout<
cout<
//这个方法是在网上找的,这里测试下是否管用
stringstream strValue;
strValue<
unsigned long long value;
strValue << value;
cout<
return 0;
}
g++ main.cpp -o transfernum
./transfernum 18446744073709551615 (这个值是2^64-1,即64位的最大值)
输出:
Input Num:18446744073709551615
transfer by atoi: 18446744073709551615 (atoi也正确了?奇怪)
transfer by atol: 9223372036854775807
transfer by atoll: 9223372036854775807
transfer by strtoull: 18446744073709551615
4196992 (使用网上找的方法发现不正确)