Monday, May 24, 2010

How to make a C/C++ program pause?

ok so I'm trying to learn C and C++, and whenever I execute the program it runs in the blink of an eye and I don't have time to see what it says, I remember there being a pause command or something that I could put in there somewhere that would wait for me to press enter, can you tell me where to put it and exactly what it's called? thank you

How to make a C/C++ program pause?
get in the habit of using getch() because it will work on all platforms (windows, unix, linux).





system("pause"); is Microsoft only.
Reply:Just add a getch(); before the last } of main. You will be fine.
Reply:There are a variety of ways -- basically you just need something that will cause the process to block.





One of these will work:


-Try reading in some input


-Use the sleep() command


-Use getch()
Reply:if the operating system is windows you can use


system("pause");


this function was declared in system.h I gues you should include the file. and for any operating system you can use scanf.


No comments:

Post a Comment