How can I rewrite my readDetails function without using stod() or strtod() in C++? The compiler I will be using doesn't have c++11 enabled and I get
'stod' was not declared in this scope error
int readDetails(SmallRestaurant sr[])
{
//Declaration
ifstream inf;
//Open file
inf.open("pop_density.txt");
//Check condition
if (!inf)
{
//Display
cout << "Input file is not found!" << endl;
//Pause
system("pause");
//Exit on failure
exit(EXIT_FAILURE);
}
//Declarations and initializations
string fLine;
int counter = 0;
int loc = -1;
//Read
getline(inf, fLine);
//Loop
while (inf)
{
//File read
loc = fLine.find('|');
sr[counter].nameInFile = fLine.substr(0, loc);
fLine = fLine.substr(loc + 1);
loc = fLine.find('|');
sr[counter].areaInFile = stod(fLine.substr(0, loc)); //line using stod
fLine = fLine.substr(loc + 1);
loc = fLine.find('|');
sr[counter].popInFile = stoi(fLine.substr(0, loc));
fLine = fLine.substr(loc + 1);
sr[counter].densityInFile = stod(fLine); //line using stod
counter++;
getline(inf, fLine);
}
//Return
return counter;
}
Below is the text I am trying to read:
Census Tract 201, Autauga County, Alabama|9.84473419420788|1808|183.651479494869 Census Tract 202, Autauga County, Alabama|3.34583234555866|2355|703.860730836106 Census Tract 203, Autauga County, Alabama|5.35750339330735|3057|570.60159846447