如何使stoi函数在dev c ++中工作 [英] how to make stoi function work in dev c++
本文介绍了如何使stoi函数在dev c ++中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用dev c ++,我不能使用stoi功能,我有点需要使用它。我搜索了如何解决谷歌中的问题但它似乎没有工作。
有另一种方法可以和stoi一样具有相同的功能。我不能使用atoi,因为我想转换字符串和atoi需要使用const char *。
谢谢。
Im using dev c++ and I cant use the stoi function and I kinda need to use it. I searched how to fix that problem in google but it doesnt seem to work.
is there an alternative way to have the same function as stoi. i cant use atoi because i want to convert a string and atoi requires const char * to be used.
thank you.
推荐答案
非常文档 [ ^ ]建议解决方法:stoi
内部调用std :: strtol(str.c_str(),& ptr,base)
,你的代码也可以完全相同(你也可以调用atoi(str.c_str())
然而strtol
是atoi $ c $的绝佳替代品c>)。
那么,如果你真的需要C ++ 11
的功能,那么你有或者更新Dev-C ++
使用的编译器,或者可能在已安装的C ++ 11
扩展上启用编译器(例如g ++
提供-std = c ++ 11
选项)。
很高兴,看到这个Stack Overflow
问题:orwell dev-c ++ support c ++ 11 [ ^ ]。
The very documentation[^] suggests a workaround:stoi
internally callsstd::strtol(str.c_str(), &ptr, base)
and your code could do exactly the same (you may also callatoi(str.c_str())
howeverstrtol
is a superior alternative toatoi
).
By the way, if you really needC++11
features, then you have either to update the compiler used byDev-C++
or, possibly, enable theC++11
extensions on the installed compiler (for instanceg++
provides the-std=c++11
option).
Plese, see thisStack Overflow
question: "orwell dev-c++ support c++11"[^].
这篇关于如何使stoi函数在dev c ++中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文