C++ MFC Problem

Associate
Joined
5 Oct 2004
Posts
1,647
I'm having some trouble with one of my loops in my MFC program

I'm very much a beginner so go easy on me!

What is happening is that the first for loop checks my exclusions array to test if the data exists, if it does not then it moves to the next loop to check if the data exists there, however on the second loop it seems the nCounter variable never gets incremented, when I watch it in debug it is set at 0 when initialized and then goes to this -858993460, the program only goes two lines down into the loop too

Code:
bool flgExclude = false;

		for(int nCounter = 0; nCounter < paryExclusions->GetSize(); nCounter++)			
		{
			int nTest = 0;
			nTest =	strPath.Find(paryExclusions->GetAt(nCounter), 0);
			if(nTest != -1)
			{
				flgExclude = true;
				break;
			}
		}
	
		for(int nCounter = 0; nCounter < paryIncludes->GetSize(); nCounter++)			
		{
			int nTest = 0;
			nTest = strPath.Find(paryIncludes->GetAt(nCounter), 0);
			if(nTest == -1)
			{
				flgExclude = true;
				break;
			}
			else
				flgExclude = false;

			if(!flgExclude)
				DeleteFiles(strPath, pLogFile, nMaxAge);
		}
 
What value does paryIncludes->GetSize() have?

Does the variable which GetSize() returns get initialised to say 0 in its constructor?
 
Probably should have explained that paryIncludes is a CStringArray that I populate elsewhere in the program

paryIncludes has 3 entries in it
 
Oh (I've not touched MFC for years :D). Does paryIncludes->GetSize() return the correct figure if you debug it?
 
Does it get through the loop once before breaking? What happens if you remove the contents of the loop and just have

Code:
for(int nCounter = 0; nCounter < paryIncludes->GetSize(); nCounter++)			
{
}
 
When I step through it gets to the first curly bracket then breaks, it does this multiple times though

I'll try taking the stuff out of the loop...
 
Ok so if I take everything out of the loop then it reaches the second curly bracket and does so a couple of times which suggests its counting up through the for loop?
 
Back
Top Bottom