+ 3

How to use std::stod() properly?

I recently tried using std::stod for the code below, but I always get this error message: "stod is not a part of std". Since I am somewhat sure Sololearn's compiler features C++11, I can't find my mistake. Any help would be appreciated :) https://code.sololearn.com/cgA89VEpQiFZ/?ref=app

28th Sep 2017, 4:36 PM
Shadow
Shadow - avatar
14 Antworten
+ 11
Thanks Andrea In addition to Andrea's alternative solution, I found a second alternative to this problem by using stringstream facilities. [https://stackoverflow.com/questions/16747915/c-converting-a-string-to-double] [https://code.sololearn.com/cjY4VyCIUkVc]
28th Sep 2017, 5:15 PM
Babak
Babak - avatar
+ 10
For showing that f is really a double! :)
28th Sep 2017, 5:17 PM
Babak
Babak - avatar
+ 9
Useful as hell! Soon I wanna implement a log system for my projects using this tutorial. [http://www.drdobbs.com/cpp/logging-in-c/201804215]
28th Sep 2017, 5:23 PM
Babak
Babak - avatar
+ 9
I'm so glad to find it useful. Good luck to you and dear Andrea. @~)~~~~
28th Sep 2017, 6:09 PM
Babak
Babak - avatar
+ 8
This one isn't as good as Andrea's but not bad! ;) https://code.sololearn.com/cn62B9g73skE
28th Sep 2017, 5:55 PM
Babak
Babak - avatar
+ 3
...std::stod is only available if you are at least using std=c++11 to compile... Seems that sololearn don't use c++11. I got similar problem using to_string();
28th Sep 2017, 4:47 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
28th Sep 2017, 5:01 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 3
Not a perfect code, only for give an idea but now using strtod seems to work! https://code.sololearn.com/cKmafkv7FgO6/?ref=app
28th Sep 2017, 5:25 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 2
Thanks for all the suggestions and tipps. As a result, I could complete the code, and can now have a deeper look in what you gave me. Always good to learn something new!
28th Sep 2017, 6:02 PM
Shadow
Shadow - avatar
+ 1
why + 1.0? anyway good solution
28th Sep 2017, 5:15 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 1
Ah okey!
28th Sep 2017, 5:17 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 1
stringstream are really useful XD
28th Sep 2017, 5:18 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 1
You're welcome :D
28th Sep 2017, 6:05 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 1
You too Babak
28th Sep 2017, 6:11 PM
Andrea Simone Costa
Andrea Simone Costa - avatar