I've been struggling with getting my For loops to "start" within a function. To help me debug I tried displaying meaningful sentences in all sections of the block of code (which I removed for convenience here). Unfortunately, only the sub-function "runs". I initially had it written with the condition to be "j" despite the increment on "I". That didn't work so I tried being consistent with having the condition and the action within the loop match... still, The For loop gets completely ignored... Help?!
For context, this a tic-tac-toe exercise and this piece of code is intended to verify each line for potential victory. line1() rolls into victory1() which, if true, would end another for loop in main(). I'm obviously self-taught so I sincerely apologize if I have a terrible structure / style / optimization / etc. Any feedback is greatly appreciated.
Here's the snippet of code that get's called:
bool line1()
{
int temp = 0;
// Program runs up to here and then skips the for loop.
for (int i = 0, j = 0; i == 3; i++)
{
cout << "in line1() For Loop" << endl;
if (TableArray[i][j] == 'X')
{
if (i == 2)
{
temp = 1;
}
}
else if (j == 2)
{
i = 2;
}
else
{
j++;
}
}
if (temp == 1)
{
return true;
}
else
return false;
}