howdy again..
How would I make it so a user's input ability is terminated upon entering nothing into a field, here's what the output would look like:
student#1:
What's your name?
*user hits enter with no text*
Bad input, terminating...
*program goes onto more stuff...*
But if the user enters good input, this is what happens:
What's your name?
Blah
What's your hobby?
Blah
Here's what I have so far (there's more code...this is just a snippet):
Code:
int getinfo(student pa[], int n)
{
student temp;
int i;
for (i = 0; i < n; i++)
{
cout << "Student #" << (i + 1) << ":\n";
cout << "What's your name?\n";
cin.get(temp.fullname, SLEN).get();
if (!cin)
{
cin.clear();
while (cin.get() != '\n')
continue;
cout << "Bad input, terminating...\n";
break;
}
else
pa[i].fullname = temp.fullname;
cout << "\nWhat's your hobby?\n";
cin.get(pa[i].hobby, SLEN).get();
Now that only checks for wrong input...can that be converted or am I just not doing it right in the first place? Any answers would be awesome...thanks a lot everyone -Chap