In a file Tasks.txt, we have
23
bruh
moment
24
bruh
moment
gym
when extracting with ifstream >> we get the 23 on the first line but then it fails to get the 24 at the end
int num = 0;
std::string bufferStr;
while (true)
{
I_tasksFile >> num;
if (!std::getline(I_tasksFile >> std::ws, bufferStr))
break;
if (num > 0)
tasksDay = num;
std::cout << tasksDay;
}
what I want is to get the latest date in the file but the num variable only extracts 23 then it keeps getting zero’s.
New contributor
ParsleyJoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.