|I think this code below compiles. I only reformatted. I shortened the logic in the program as suggested and it works. The only problem I'm having is duplicate output (something I encountered last week). Below the user is prompted to enter data twice in sequence. The first time the user is prompted to make a selection from a menu screen (no big deal).
But, after the user hits the ENTER key, the user will see duplicates of the second prompt. It is as if the user hit the enter key twice.
How do I prevent this from happening? Better question . . . Why is it happening?
I know the compiler is taking me thru the while loop an extra time which is printing the duplicate prompt (confirmed by the debugger).
using namespace std;
unsigned int value;
cout << "A) Complete B) Partial C) UNKNOWN" << endl;
cin >> selection;
bool validEntry = false;
cout << "Please enter the number of subunits: ";
cin.getline(buff, 1023, '\n');
if (sscanf(buff, "%u%n",&value,&charsRead)==1 && value >=1 && value <= 12)
validEntry = true;
data2 = value;
-- modified at 21:56 Wednesday 12th July, 2006