gpt4 book ai didi

c++ - 错误 : 'stod' was not declared in this scope

转载 作者:行者123 更新时间:2023-11-30 04:10:52 29 4
gpt4 key购买 nike

我正在为一个 C++ 项目工作,我需要将字符串转换为 double 字符串,但我一直收到错误“stod”未在此范围内声明。快速回复将不胜感激!

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>

using namespace std;

struct Station
{
string StationID, StationName;
double Elevation, Latitude, Longitude;
int Date, MXPN, MaxTemp, MinTemp, ObsTime;
};

int main()
{
//Initial Variables
ifstream InputFile;
vector<Station> Entry;
string DummyLine, TempLine;
double TempDouble;
int Counter = 0;


InputFile.open("finalc++.csv");
getline(InputFile, DummyLine);
while (InputFile.good())
{
Entry.push_back(Station());
getline(InputFile, TempLine);
stringstream ss (TempLine);
getline(ss, DummyLine, ',');
Entry[Counter].StationID = DummyLine;
getline(ss, DummyLine, ',');
Entry[Counter].StationName = DummyLine;
getline(ss, DummyLine, ',');
Entry[Counter].Elevation = stod(DummyLine);
Counter++;
}
for (int i = 200; i <= 500; i++)
{
cout << Entry[i].StationID << endl;
cout << Entry[i].StationName << endl;
}

return 0;
}

我必须包含一些库才能使用它吗?顺便说一句,我在 Windows 机器 x86 上使用代码块 12.11。

最佳答案

这是 gcc 4.x 的一个已知错误

启用 c++11 stardarts,取决于您的 IDE,在 CodeBlocks 中转到:设置,编译器并选中“让 g++ 遵循 c++11 ISO...”如果您使用的是 gcc 编译器;

关于c++ - 错误 : 'stod' was not declared in this scope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20437984/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com