Ok, there has to be a MAJOR logic error made by me here. With the following code, the message boxes cycle through: "playflag is true", "playflag is false", "we have a match", and it goes through that cycle about 5 times. After you look at the code, you'll see that after playflag is set to true, it should never get inside that chunk of code again, unless playflag is somehow set to false again. And of course, the only time I see the message "playflag is true" is when it gets inside that chunk of code it should never go into again. and i see "playflag is true" multiple times. which makes it seem to me, that playflag is being set to false where i don't want it to be, or something like that. see what i mean its confusing...and really messing up my program as well....have a look see if you can identify my logic error:
Code:
void CheckTimes(char sometime[6], HWND hList)
{
char* temp[1000];
for(int i=0; i<1000; i++)
{
temp[i] = new char[50];
strcpy(temp[i], ".");
}
i=0;
for(int x=0; x<1000; x++) //Trouble loop
{
if(strcmp(times[x], ".")!=0) //means there is real info
{
strcpy(temp[i], times[x]);
i++;
}
}
bool leeman = false;
bool playflag = false;
for(x=0; x<i; x++)
{
if(!playflag)
MessageBox(NULL, "playflag is false", "playflag is false", MB_OK);
if(playflag==false)
{
if(strcmp(temp[x], sometime)==0) //they match
{
MessageBox(NULL, "we have a match", "we have a match", MB_OK); //DOES POP UP, MULTIPLE TIMES
playflag = true;
if(playflag)
MessageBox(NULL, "playflag is true", "playflag is true", MB_OK);
//Sleep(1000);
for(int a=0; a<1000; a++)
{
if(!leeman)
{
if(strcmp(times[a], temp[x])==0)
{
strcpy(times[a], "."); //removes entry we just used up
RemoveByIndex(temp[x], hList);
SaveTimes();
leeman = true;
}
}
}
}
}
}
}