Solved

Stop console from closing

Posted on 2004-09-10
3
767 Views
Last Modified: 2012-06-27
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
Comment
Question by:adecold
  • 2
3 Comments
 

Accepted Solution

by:
s_senthil_kumar earned 200 total points
ID: 12029796
#include <conio.h>

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

That should solve your problem.
0
 
LVL 6

Author Comment

by:adecold
ID: 12030923
Thanks a lot....
But can you explain to me what theat function actually does.
0
 

Expert Comment

by:s_senthil_kumar
ID: 12033797
getch() waits for a character from standard input. So that causes the console to stay until you press a key.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question