源码:
#include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned long long tmp_ll;
tmp_ll = atoll("0000000000000002");
printf("tmp_ll : %lld \n", tmp_ll);
tmp_ll = atoll("122323");
printf("tmp_ll : %lld \n", tmp_ll);
tmp_ll = atoll("122323344");
printf("tmp_ll : %lld \n", tmp_ll);
tmp_ll = atoll("112233445566");
printf("tmp_ll : %lld \n", tmp_ll);
tmp_ll = atoll("11223344556677");
printf("tmp_ll : %lld \n", tmp_ll);
tmp_ll = atoll("1122334455667788");
printf("tmp_ll : %lld \n", tmp_ll);
tmp_ll = atoll("11223344556677ff");
printf("tmp_ll : %lld \n", tmp_ll);
}
运行:
root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/03_test/01_C/3_file# gcc -o 6 6.c
root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/03_test/01_C/3_file# ./6
tmp_ll : 2
tmp_ll : 122323
tmp_ll : 122323344
tmp_ll : 112233445566
tmp_ll : 11223344556677
tmp_ll : 1122334455667788
tmp_ll : 11223344556677
root@ubuntu:/mnt/hgfs/Ubuntu12.04-share/03_test/01_C/3_file#
转化出来的是长长整型十进制,不是十六进制。所以字符串中不能出现字母。
很基本的C语言知识。