Bład w kompilacji 'stod' is not a member of 'std'
Ostatnio zmodyfikowano 2016-01-07 21:11
hubr Temat założony przez niniejszego użytkownika |
Bład w kompilacji 'stod' is not a member of 'std' » 2016-01-06 18:02:54 Mam pilną potrzebę zamiany w programie string na double. Spróbowałem najpierw skompilować jakiś przykładowy program z internetu: #include <iostream> #include <string.h>
int main() { double stod( const std::string & str, std::size_t * pos = 0 ); double stod( const std::wstring & str, std::size_t * pos = 0 ); std::string orbits( "365.24 29.53" ); std::string::size_type sz; double earth = std::stod( orbits, & sz ); double moon = std::stod( orbits.substr( sz ) ); std::cout << "The moon completes " <<( earth / moon ) << " orbits per Earth year.\n"; return 0; }
C:\Users\Aspire5750G\Desktop\Symfonia C++\RPG\zamiana.cpp||In function 'int main()':| C:\Users\Aspire5750G\Desktop\Symfonia C++\RPG\zamiana.cpp|14|error: 'stod' is not a member of 'std'| C:\Users\Aspire5750G\Desktop\Symfonia C++\RPG\zamiana.cpp|15|error: 'stod' is not a member of 'std'| ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Przeczytałem parę anglojęzycznych tematów, ludzie radzili żeby dodać flagę -stdlib=libc++, jednak to nie działa. EDIT: korzystam z code::blocks 13.12 |
|
Monika90 |
» 2016-01-06 18:12:37 flaga powinna być taka -std=c++11, albo taka -std=c++14, a program taki #include <iostream> #include <string>
int main() { std::string orbits( "365.24 29.53" ); std::string::size_type sz; double earth = std::stod( orbits, & sz ); double moon = std::stod( orbits.substr( sz ) ); std::cout << "The moon completes " <<( earth / moon ) << " orbits per Earth year.\n"; return 0; }
|
|
hubr Temat założony przez niniejszego użytkownika |
» 2016-01-07 20:06:13 Nic nie pomaga, uwzięło się to na mnie, Jest jakaś inna opcja zamiany tych zmiennych? |
|
mateczek |
» 2016-01-07 20:11:43 |
|
hubr Temat założony przez niniejszego użytkownika |
» 2016-01-07 21:11:16 Mam dokładnie tak jak pokazałeś, kompilator jest uparty, ale znalazłem jakiś zamiennik, a długo się naszukałem: Może komuś się przyda: std::string num = "0.6"; double temp =::strtod( num.c_str(), 0 );
|
|
« 1 » |