Advertisement

Quick question!

Started by January 24, 2003 06:10 PM
4 comments, last by virus3355 21 years, 9 months ago
how do i stop my program from closing after it completes the code? like wait for a key press then close, or something like that. Thanks for helping a NUB! :D
If it''s a console program (ie: black window, white text... looks like DOS) you can just put a cin>> at the end. You could also use the Sleep() function to have it delay a few seconds.
Peon
Advertisement
isn''t there also a getline() function that you can use instead of the cin>> ?

--------------
In the immortal words of a MST3K ape: "MAYONAAAASE"
--------------In the immortal words of a MST3K ape: "MAYONAAAASE"
getch(); (found in stdlib.h)

and system("pause"); (likewise in stdlib.h)

will also do the trick.

[twitter]warrenm[/twitter]

is there anything else i have to do in order to use getch(); ?

it gives me an error.


thanks..


P.S. system("pause"); works.


[edited by - virus3355 on January 24, 2003 10:07:38 PM]
try including <conio.h> or use getchar(); from <stdio.h> (which is essentially the same as a cin).

This topic is closed to new replies.

Advertisement