Trivial issue

In the following code for some reason, the variable iTileCount will not re-initialize itself through the 2nd and 3rd iterations of the nested for loops. I stepped through it and watched it, but doesn't change on the re-initialization. Anybody???

int iTileCount = 0; // initialize counter of consecutive tiles
// check for win
for (int i = 0; i < 3; i++)
{
iTileCount = 0; // Will not set iTileCount to 0<<**********
for (int j = 0; j < 3; j++)
{
// check to see if the user's tile is on the board at the specified location
if (theBoard[i][j] == cPlayerMark)
iTileCount++;
}
// has enough tiles in a row. user has won.
if (iTileCount == 3){
bGameOver = true;
bWinGame = true;
}
}
If you don;t need it outside the for loop you can define it inside the for loop instead of outside:
1
2
3
4
for(blah; blah; blah)
{
	int ThisVarWillReset = 0;
}


Although your code looks fine. What compiler are you using?
Topic archived. No new replies allowed.