Help fixing function header

Hi there, pretty new to programming and I would appreciate if someone more experienced could give me some pointers on what to correct in my code. I'm getting a compiling error that is saying "could not convert... from void to bool" in reference to line 40 which contains "getTrialElements(inFile, elementArray)" in my int main

I'm assuming I made some kind of simple and obvious mistake in my function header but I am unsure as to what that might be. Below is the beginning of my code, the function definitions have been left out for brevity's sake. For this assignment I am NOT allowed to change the int main

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>


using namespace std;


const char* IN_FILE_NAME = "stats.txt";
const char* OUT_FILE_NAME = "results.txt";
const int ELEMENTS = 100;


// Function Prototypes
void getTrialElements(ifstream&, double[]);
void sortArray(double[], int);
double findMean(double[], int);
double findMedian(double[], int);
double findMinimum(double[], int);
double findMaximum(double[], int);
double standardDeviation(double[], int);
void printTrialResults(ofstream&,int, double[]);




int main()
{
ifstream inFile;
ofstream outFile;
int trialNumber = 0;
double elementArray[ELEMENTS];


inFile.open(IN_FILE_NAME);
outFile.open(OUT_FILE_NAME);


while(getTrialElements(inFile, elementArray))
{
trialNumber++;
printTrialResults(outFile, trialNumber, elementArray);
}


outFile.close();
inFile.close();


return 0;
}
Well the issue is that getTrialElements returns type is of type void. However, in line 40 you are using that function in the while loop as a means of a flag. Thus, the compiler issues an error that it can't convert void, the return type of getTrialElements, to bool. To fix this have getTrialElements return type be of type bool, or any type that can be converted to bool.
Topic archived. No new replies allowed.