What is atoi equivalent for 64bit integer(uint64_t) in C that works on both Unix and Windows?

前端 未结 7 1520
失恋的感觉
失恋的感觉 2021-02-02 08:02

I\'m trying to convert 64bit integer string to integer, but I don\'t know which one to use.

7条回答
  •  攒了一身酷
    2021-02-02 08:31

    Something like...

    #ifdef WINDOWS
      #define atoll(S) _atoi64(S)
    #endif
    

    ..then just use atoll(). You may want to change the #ifdef WINDOWS to something else, just use something that you can rely on to indicate that atoll() is missing but atoi64() is there (at least for the scenarios you're concerned about).

提交回复
热议问题