Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, 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.
Posted

1 solution

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"[^].
 
Share this answer
 
v3
Comments
Reuben Cabrera 8-May-15 4:26am    
how can i enable c++11 extensions?
CPallini 8-May-15 9:42am    
I have updated my answer.
Reuben Cabrera 8-May-15 12:14pm    
thank you. i was able to use it now :)))
CPallini 8-May-15 13:01pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900