Arturito.net

Come to The Dark Side, We Have Cookies!

C++ Press any key to continue

without comments

When I write some console application in Bloodshed Dev C++ or Visual Studio, I hate bringing up comand line and typing in the whole path to the program I’ve just written. I found two short ways of having “Press any key to continue…” before the console window disappears. One of them is a good one and the other is bad.

1. Good one

int main()

{

// do something

cout<<"Press Enter to continue...";
cin.get();
}

Well, this one really is "Press Enter to continue...", which shouldn't be a problem :-)

2. Bad one

int main()
{

// do something

system.("PAUSE");
}

This one is very bad! If you want to know why, read this article:

http://www.gidnetwork.com/b-61.html

Written by guru

April 21st, 2009 at 1:19 pm

Posted in C++