In this function I made, it takes input which will always be in the format: xx:xx like a time. For example 17:05. In military time. times[] could possibly hold the same info somewhere. so i check all through the array times[] for a match. when there is a match, i want a messagebox to come up, which is in the code. the only problem is, the messagebox comes up a TON of times, not just once. i thought i stopped it from being done a bunch of times by using playflag. (its called playflag because eventually it will play a sound). Anyway, heres the code - any help is appreciated:
EDIT: ooh, and this function is run many times over and over again. but you see i set the element in times[] to a "." which signifies no entry. So when it is run again, it shouldn't find anything there, i'm not sure what the problem is
Code:
void CheckTimes(char sometime[6])
{
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 flag = false;
bool playflag = true;
for(x=0; x<i; x++)
{
if(playflag)
{
if(strcmp(temp[x], sometime)==0) //they match
{
MessageBox(NULL, "we have a match", "we have a match", MB_OK);
playflag = false;
for(int a=0; a<=999; a++)
{
if(!flag)
{
if(strcmp(times[a], sometime)==0)
{
strcpy(times[a], "."); //removes entry we just used up
flag = true;
}
}
}
}
}
}
}