Answer the question
In order to leave comments, you need to log in
How does the cin.peek function work?
while (!(cin >> b) || (cin.peek() != '\n') || (b <= 0))
{
cin.clear();
while (cin.get() != '\n');
cout << "Error enter!\n";
cout << "to begin again, press any key...\n";
}
Answer the question
In order to leave comments, you need to log in
Which robot do you propose to explain?
And in the case - do you have a refman banned chtoli?
Looks at the next character without moving the cursor so-and-so.
Could you describe this algorithm (code) point by point, what happens behind what.
while (!(cin >> b) || (cin.peek() != '\n') || (b <= 0))
{
cin.clear();
while (cin.get() != '\n');
cout << "Error enter!\n";
cout << "to begin again, press any key...\n";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question