• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 777
  • Last Modified:

Stop console from closing

Hey,
   I just started learning c programming. I started learning with Visual studio.net and ther was an option there that has "start without debugging" under debugging. The thing is i can't use that Visual studio anymore(I'm now trying to use visual studio express 2005 beta 1, or Dev-C++), and other compilers don't have start without debugging...
  So.. now when i run a program straight from windows, the program just runs and the console goes away almost immediately.

QUESTION: is there something i can put in my code that stops the console from closing when the program ends.(or is there something i can do to Visual studio express to allow the console to stay.)

THanks
0
adecold
Asked:
adecold
  • 2
1 Solution
 
s_senthil_kumarCommented:
#include <conio.h>

int main()
{
    // Do something
   getch();
}

That should solve your problem.
0
 
adecoldAuthor Commented:
Thanks a lot....
But can you explain to me what theat function actually does.
0
 
s_senthil_kumarCommented:
getch() waits for a character from standard input. So that causes the console to stay until you press a key.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now