Thank you everyone for the help. I simply misread the code. The answer is
count = 0;
for (i = 0; i < n; ++i);
{
scanf("%d", &X);
if (X == i)
{
++count;
}
}
For some reason the if statement didn't resonate in my head that it was there, so I over complicated the problem. But thank you everyone for your input.