int coefficient, exponent;
success = true // assume read is successful
cin >> coefficient >> exponent;
if (cin.eof())
{
success = false;
}
while (!cin.eof() && success)
{
if ((MIN_INDEX <= exponent) && (exponent <= MAX_SIZE - 1))
{
p[exponent] = coefficient;
}
else if ((exponent < MIN_INDEX) || (exponent > MAX_SIZE -1))
{
cout << "Error - invalid exponent (Must be between 0 and 20 inclusively)" << endl << "Please try again..." << endl << endl;
success = false;
}
cin >> coefficient >> exponent;
}
return;
I have tried to the coefficient and exponent into an array. Whenever the user hits ctrl d, the read is terminated and array is successfully loaded. But somehow, after ctrl d, my program runs an infinite loop. Please help me to fix this. Thank you.