The vector contains only the numerical values since it is reading them in as integers. However, how can I check the file for non-integers? For example, if it sees that "A", I want to throw an error and return -1.
vector<double> nums; // vector to hold numbers from the file.
bool Numbers::Read (istream& istr) // read in the numbers from the file
{
ifstream inputFile("nums.txt"); // open the file for reading
if (inputFile)
{
float meanTotal = 0.0; // mean value
double result; // result of the numbers being added together
int count; // count the amount of items in the file
while (inputFile >> count) // read the numbers into the vector
{
nums.push_back(count);
++count;
}
inputFile.close();