错误位于第25行的括号内。程序读取,计数和平均文件数据文件上的值。我不知道它是什么我检查了分号和代码中的所有内容。它不会编译。
#include <iostream>
#include <fstream>
using namespace std;
void ReadAndSum(ifstream&, int&, float&); // Reads, counts, and averages the values on file dataFile.
int main()
{
ifstream dataFile;
int numberOfValues;
float average;
cout << fixed << showpoint;
dataFile.open("Averages.txt");
ReadAndSum(dataFile, numberOfValues,average);
cout << "The average of " << numberOfValues << " values is " << average << endl;
return 0;
}
void ReadAndSum(ifstream& dataFile, int& numberOfValues, float& average);
{
float number;
numberOfValues = 0;
average=0;
dataFile >> number;
while (dataFile)
{
average = average + number;
numberOfValues++;
dataFile>>number;
}
average = average/numberOfValues;
}
答案 0 :(得分:1)
void ReadAndSum(ifstream& dataFile, int& numberOfValues, float& average);
以上的行以分号结尾,摆脱它,这应该可以解决您的问题。