From what I can see:
1. You are using the variable i for the loop, but then you are using variable index for the array.
You have not initialized index to be a number.
for(int i =0; i < 2000; i++)
{
cout << i << array[i] << endl;
}
if(array[index] == 0)
{
c0++;
}
So, I would change these 2 lines from:
for(int i =0; i < 2000; i++)
{
cout << i << array[i] << endl;
to
for(index =0; index < 2000; index++)
{
cout << i << array[index] << endl;
That should solve 1 problem.
Another problem is, are you sure there are 2000 entries in the file for the array?
Basically, you would be checking all 2000, even if the file only contained 2. So the count would be off.
See the next problem as well.
Next problem. You are not getting the information from the file and putting it in the array. At the end of the file, if the contents have not been 2000, then you could put in a value that says it is the end of the data. This could be -1, or something. Then if you find -1 you break out of the loop (using the break; statement.
When you read the contents of the file into the array, you need to make sure you are only putting 1 digit into each spot of the array. if you don't do this, then you may have 10 as the value and this would not count as either a 1 or a 0.
Also, you can use if - else if statements instead of just if, if, if, etc.
if(array[index] == 0)
{
c0++;
}
else if(array[index] == 1)
{
c1++;
}
else if(array[index] == 2)
You may want to use a switch statement instead if you have learnt them.
Hope that helps.