I'm working on a project for c++ and I need to convert a string to a double but I keep getting the error 'stod' was not declared in this scope. Hasty replies would be greatly appreciated!
#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;
}
Is there some library that I have to include to be able to use it? btw I'm using codeblocks 12.11 on a windows machine x86.