C++ 将字符串转换为 long long
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/303759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
convert string to long long
提问by Alonso
I'm using VS 2008 to create a C++ DLL (not managed) project and I need convert a char* to a long long type. Is there an easy way to do it?
我正在使用 VS 2008 创建一个 C++ DLL(非托管)项目,我需要将 char* 转换为 long long 类型。有没有简单的方法来做到这一点?
Thanks in advance :)
提前致谢 :)
采纳答案by altruic
Try _atoi64.
This takes char*
and returns __int64
.
Try_atoi64.
这需要char*
并返回__int64
。
回答by Alan
回答by Ryan Ginstrom
If you're using boost, lexical_cast is the way to go, in my opinion.
如果您使用的是 boost,我认为 lexical_cast 是您要走的路。
long long ll = boost::lexical_cast<long long>(mystr)