开发者

Is there a stoll()/stroll() (string to long long) alternative in Visual Studio 2008

开发者 https://www.devze.com 2023-01-04 18:05 出处:网络
Is there an alternative, either built into windows or apache license compatible, to stoll() for Visual Studio 2008. Even installing the windows 7 platform SDK does not add stoll() to the string header

Is there an alternative, either built into windows or apache license compatible, to stoll() for Visual Studio 2008. Even installing the windows 7 platform SDK does not add stoll() to the string header.

On unix the sam开发者_高级运维e function is be called strtoll().


You can use _strtoi64. It's declared in stdlib.h.

long long num = _strtoi64(str, NULL, 10);

Similarly to strtoll, you can pass a char ** endptr as a second parameter. If so, *endptr will be set to the first invalid character (which may be the normal null-terminator).


Visual Studio 2013 added strtoll(), so if you can depend on that you can use strtoll() directly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号