I am having a lot of trouble getting the following to work and I think it is because of file issues:
int GetMinutes()
{
fstream file(FNAME);
char num[101];
if (!file.is_open())
Error("FILE NOT OPEN!");
file.getline(num,100);
file.close();
return atoi(num);
}
int main(int argc, char *argv[])
{
LARGE_INTEGER timestart, timestop, tickspersecond;
QueryPerformanceFrequency(&tickspersecond);
QueryPerformanceCounter(×tart);
Sleep(5);
HWND window=GetForegroundWindow();
int minutes=GetMinutes();
char *caption;
sprintf(caption, "%i minute timer.", minutes);
bool counting=true;
do
{
QueryPerformanceCounter(×top);
int secondsleft=(minutes*60)-((timestart.QuadPart-timestop.QuadPart)/tickspersecond.QuadPart);
char *message;
sprintf(message, "%02i:%02i.%02i", secondsleft/3600, (secondsleft-((secondsleft/3600)*3600))/60, secondsleft-(((secondsleft-((secondsleft/3600)*3600))/60)*60)-((secondsleft/3600)*3600));
counting=(secondsleft>=0);
}while (counting);
I left out some of the code that I wish to keep to myself. But I have isolated the problem and it seems as though while loop is never excecuting. This happened before I changed from while{} to do{}while as well. Any ideas why this isn't working?