Visual Studio 2008 中是否有 stoll()/stroll() (字符串到 long long)替代方案

Jus*_*ing 3 c++ windows visual-studio-2008 visual-c++

对于 Visual Studio 2008 ,是否有另一种方法(内置于 Windows 或与 apache 许可证兼容)来替代stoll()。即使安装 Windows 7 平台 SDK 也不会将 stoll() 添加到字符串标头。

在 unix 上,相同的函数被称为strtoll()

Mat*_*hen 5

您可以使用_strtoi64。它是在 中声明的stdlib.h

long long num = _strtoi64(str, NULL, 10);
Run Code Online (Sandbox Code Playgroud)

与 类似strtoll,您可以传递 achar ** endptr作为第二个参数。如果是这样,*endptr将被设置为第一个无效字符(可能是正常的空终止符)。

  • 这就是标准的伟大之处,有这么多可供选择。 (3认同)