Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

system("pause") clarification

When i use system("pause"), then a line "Press any key to continue..." shows up on the screen.

This is iritating and makes reading the output quite cumbersome.

Is there some way to stop this from coming?

like image 996
IcyFlame Avatar asked Oct 18 '25 15:10

IcyFlame


2 Answers

Do you mean that you want to press any key to continue but not to display the "Press any key to continue" on the screen? Try this getchar(); this will capture one character typing from keyboard and continue.

like image 52
David Fang Avatar answered Oct 21 '25 05:10

David Fang


Rather than using platform dependent system("pause") you can use the platform independent std::cin.get() and if the buffer is messing with it, you can use:

std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n')

before hand to clear the buffer.

like image 26
Rapptz Avatar answered Oct 21 '25 03:10

Rapptz