This is for a homework assignment - just can't understand why display won't pause. Searching online, saw info on std::cin.get();
Using it, but not sure why it still won't pause.
Have some programming experience but not C++.
Any help would be appreciated.
Thanks
Code follows:
#include <iostream>
#include <fstream>
using namespace std;
const int NUMROWS = 20;
bool inRange (double MyArray[NUMROWS], double inElement) {
// the following variables store
// MIN and MAX array elements
// and their indexes
double dMin = MyArray[0];
double dMax = MyArray[0];
// process array elements
// to find MIN and MAX
for (int i=1; i<NUMROWS; i++)
{
if (MyArray[i] < dMin)
{
dMin=MyArray[i];
}
if (MyArray[i] > dMax)
{
dMax=MyArray[i];
}
}
//If "tunnel_ordered.txt" is not available,
//Exit with an error message
ifstream inputFile("tunnel_ordered.txt");
if (!inputFile)
{
// Print an error and exit
cerr << "Input file not available! Press enter to continue" << endl;
std::cin.get();
return 1;
}
int count;
double angles[NUMROWS]; //Declare array angles
double col[NUMROWS]; //Declare array col
//For count = 1 to NUMROWS,
for (count = 0; count < NUMROWS; count++)
{
inputFile >> angles[count]; //Read flight angles into angle array
inputFile >> col[count]; //Read COL into COL array
}
inputFile.close();
cout << "The entries from input file are " << endl;
I have std::cin.get(); in 3 places. The first one does work; the output will wait until Enter is pressed, the other two places it doesn't pause. I can see it when I run it through debug.