strtoull and long long arithmetic

前端 未结 3 1721
日久生厌
日久生厌 2020-12-11 10:42

Can anyone explain the output of this program and how I can fix it?

unsigned long long ns = strtoull(\"123110724001300\", (char **)NULL, 10);
fprintf(stderr,         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 10:53

    I cannot explain the behavior. However, on 32 bit Windows XP with Cygwin gcc-4.3.2:

    #include 
    #include 
    
    int main(void) {
        unsigned long long ns = strtoull("123110724001300", NULL, 10);
        fprintf(stderr, "%llu\n", ns);
        return 0;
    }
    

    prints

    E:\Home> t.exe
    123110724001300
    

提交回复
热议问题