cin.ignore.get() causing my program to stuck on input

48 Views Asked by At

I have been instructed by my professor to use this code block below in my program.

void enter_to_continue() {
    cout << "Press enter to continue...";
    cin.ignore().get();
}

However, this code block does not work as expected. And no matter how many times I press Return, the program does not continue. Is this the proper way to implement it? (Also, while this may seem like a simple question, I have not found any other answers thus far.)

Compiled using g++ 11.4.0 on Ubuntu.

0

There are 0 best solutions below