I've been creating an idle program to count in minutes when the mouse and keyboard are inactive. This is what I have so far:
using namespace std;
while(true)
{
GetLastInputInfo(&last_info);
tickCount = GetTickCount();
int minutes = (tickCount - last_info.dwTime) / 60000;
count++;
if((minutes >= 1) && (count%3000==0))
{
ifstream in("in.txt");
ofstream out("out.txt");
float sum;
in >> sum;
sum = sum++;
out << sum;
out << in.rdbuf();
out.close();
in.close();
}
std::cout << "Idle Time: " << minutes << " minutes." << std::endl;
}
}
When I run it idle for one minutes the "sum" says it's 1, I then close the program and open it up for one minutes again and the "sum" says it's 2. I close the program and open it for one more minute and it's back down to 1. Why is this happening?