Contents Up << >>

Why is my program ignoring my input request after the first iteration?

Because the numerical extractor leaves non-digits behind in the input buffer.

If your code looks like this:

  	char name[1000];
	int age;

	for (;;) {
	  cout << "Name: ";
	  cin >> name;
	  cout << "Age: ";
	  cin >> age;
	}
What you really want is:

  	for (;;) {
	  cout << "Name: ";
	  cin >> name;
	  cout << "Age: ";
	  cin >> age;
	  cin.ignore(INT_MAX, '$\backslash$ n');
	}