1

In windows when compiling, system("pause") works, what is the equivalent in linux?

1 Answer 1

1

The following works on windows and linux/unix:

std::cout << "Press \'Return\' to end." << std::endl;
std::cin.flush();
std::cin.get();

The first std::cin.flush() clears the input que, the next command waits for an input.

3
  • I'm getting this: std::istream {aka class std::basic_istream<char>}’ has no member named ‘flush’
    – Utshaw
    Jan 3, 2019 at 9:34
  • Can you try to use std::cin.flush().
    – Videonauth
    Jan 3, 2019 at 9:42
  • I am using using namespace std . & tried your way too. But no improvement.
    – Utshaw
    Jan 3, 2019 at 11:32

Not the answer you're looking for? Browse other questions tagged .