When I compile my code,I got this error
and my code is
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
string str,str2;
cin>>str>>str2;
float a,b;
a = stof(str); //error
b = stof(str2); //error
cout<<a+b;
return 0;
}
how to resolve this ??
此外, std::stof
只能使用 c++11 版本编译,编译应为:
g++ -std=c++11 code.cc
std::stof
位于标准 C++ 头文件<string>
。
With dev c++ you need to go to Project > Project Options (Ctrl +h) > Compiler > Code generation > Language standard and select GNU C++ 11
(Not too sure about the menu since i have the language set to italian but it's pretty much that)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.