Q:

I am trying to read numbers from a file

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
using namespace std;
int v[101];

int main()
{
int max=0; int a,i;
ifstream f("bac.in");
ofstream g("bac.out");

while(!EOF(f))
{
    f >> a;
    while(a>10)
      if(a%10!=0 && (a/10)%10!=0)  v[a%100]++;
    a/=10;
}
for(i=10;i<=99;i++) if(v[i]>max) max=v[i];
for(i=10;i<=99;i++) if(v[i]==max) g<<i;

}

I get the error 14 | error: '-1' cannot be used as a function
If i use eof instead of EOF i get the error 'eof' was not included in this scope but i have already included cstudio or studio.h
What should i change?

A:

EOF is not a function, it's a constant. However, you shouldn't be using eof to find the end of file anyway (here is why).
Put reading itself into loop header, like this:
while(f >> a) {
    while(a>10)
      if(a%10!=0 && (a/10)%10!=0)  v[a%100]++;
    a/=10;
}

The reason this works is that f >> a, which returns istream, has a conversion operator* which allows the expression to be used as a condition. When the read is successful, the resultant condition evaluates to true; otherwise, it's false.
* The details of the conversion are different in C++98 and C++11/14, but the expression remains valid regardless of the C++ standard.

