std :: atof或std :: stof(c ++ 11)无法正确转换(“ 1.24”)

bar*_*tux 5 c++ atof string-conversion c++11

我发现这种奇怪的atof / stof行为后,我有点沮丧

double bg = std::stof("1,24");
std::cerr<<"comma: "<<bg<<std::endl;
bg = std::stof("1.24");
std::cerr<<"dot: "<<bg<<std::endl;
Run Code Online (Sandbox Code Playgroud)

当我将字符串格式从逗号更改为点时,会发生以下情况:

comma: 1.24
dot: 1
Run Code Online (Sandbox Code Playgroud)

有没有人遇到这个问题?谢谢

巴特