I think I understand why I get the segmentation fault error (tie_count will be 0 and I tried to use it outside the loop). But how do I get to condition the variables that changed inside the loop after the loop has been finished? or am i brain ded?
int x = 0, tie_count = 0, tie[8];
for (int i = 0; i < 10; i++)
{
if ( //anything here )
{
//anything here
}
else
{
tie[x] = 1;
x++;
tie_count++;
}
}
if (tie_count > 1)
{
printf("%there is tie.\n");
}
else
{
printf("no tie.\n");
}
tie_countvariable after the loop has nothing to do with seg.fault.