Quote Originally Posted by Eri523 View Post
Which side effects should that be besides flushing the stream and resetting the error control state?
It's up to debate, but I would say those are side effects yes. IMO, pausing a program and its input are two completely un-related things.

Consider especially that some command-line programs' input stream are not the keyboard, but the raw output stream of other programs (think LAME.exe, x264.exe etc.). The side effect would be the program not stopping, and the stream being completely corrupted.

Of course, those aren't toy programs anymore, but even for a toy program, try this:

Code:
int main()
{
    pause();
}
This is what my console looks like:
Code:
Please press enter...
hello world!<return>
What's up?<return>
-------End program
The program ask me to press enter, but it first lets me write an entire sentence because it is trying to flush the stream. Then, I get to write another sentence, before the program validates my input. It feels strange, because I expect to just hit space.

Also, try this:

Code:
int main()
{
    std::string name;
    std::string surname;
    std::string age;

    std::cout << "Please type your Name, Surname and age seperated by spaces" << std::endl;
    
    std::cin >> name;
    std::cout << "Your name is " << name << "!" << std::endl;
    pause();

    std::cin >> surname;
    std::cout << "Your surname is " << name << "!" << std::endl;
    pause();

    std::cin >> age;
    std::cout << "Your age is " << name << "!" << std::endl;
    pause();
}
Am I nitpicking? A bit. Yes. But I find the crusades against system("pause") to be a bit silly.