如何使stoi函数在dev c ++中工作 [英] how to make stoi function work in dev c++

查看:401
本文介绍了如何使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 ++ 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 calls std::strtol(str.c_str(), &ptr, base) and your code could do exactly the same (you may also call atoi(str.c_str()) however strtol is a superior alternative to atoi).

By the way, if you really need C++11 features, then you have either to update the compiler used by Dev-C++ or, possibly, enable the C++11 extensions on the installed compiler (for instance g++ provides the -std=c++11 option).


Plese, see this Stack Overflow question: "orwell dev-c++ support c++11"[^].


这篇关于如何使stoi函数在dev c ++中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆