I have to calculate the average of the numbers saved in the file, but I get the "+" operator error. What's the problem?
int main()
{
int a;
fstream File;
string Line;
File.open("file.txt", ios::in);
if (File.is_open()){
while(!File.eof()) //.eof -> End Of File
{
File>>Line;
a=a+Line;
cout<<Line<<"\n";
cout << a;
}
}
else{
cout << "File open error";
}
File.close();
return 0;
}