While using get_time() to get the value, the first line keeps giving 0 for tm.year while the second line works normally. Could I know what mistakes I have made?
The function is here:
void Log_Residental_Price_Index()
{
std::fstream file;
file.open("Residental Price Index.csv", std::ios::in);
struct tm RecordXX = {0};
std::string line;
std::string field;
while (getline(file, line))
{
std::cout << line << std::endl;
std::stringstream line_(line);
while (getline(line_, field, ','))
{
std::stringstream field_(field);
field_ >> std::get_time(&RecordXX, "%d/%m/%Y");
std::cout << RecordXX.tm_year << std::endl;
break;
}
}
}
Content of Residental Price Index.csv:
1/1/1993,90.4,81.3,80.7,74.2,58.1
1/2/1993,90.5,82.6,81.3,74.9,62.2
Output:
1/1/1993,90.4,81.3,80.7,74.2,58.1
0
1/2/1993,90.5,82.6,81.3,74.9,62.2
93
Could I know what mistake I have made? I am stuck on this problem for so longgg Thank you so much!