CMD from excute closing instantly

Hello, I compiled/built a code I had and made an executed file but when i click on it the CMD closes instantly. Is there anyway to keep this open?

I'll try to figure that out, thanks. A bit confusing right now but I'll play around with it.
add:
system("pause");

at the end of your codes.
example:
1
2
3
4
5
6
void main()
{
//your codes here blah blah
//...
system("pause");
}
@ tnavid: I've pretty much given up on discouraging the use of the "system()" function, but if you're going to suggest it then you HAVE to remind people to include the cstdlib header file. Also, main must return an integer. That's part of the standard.
why main must return integer? as you see it's "void main"
"main" function like other functions can be anytype: int,void,..
but you are right about stdlib header.
I know it's dryer then dust but, please, humor me for a minute: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf

The entry at the top of page 62 is what I was referring to.

An implementation shall not predefine the main function. This function shall not be overloaded. It shall
have a return type of type int,
but otherwise its type is implementation-defined.


Also here on the isocpp faq page ...

https://isocpp.org/wiki/faq/newbie#main-returns-int
I've read in a lot of places that using system("pause"); isn't the best thing to do. I mean I'll give it a try and see if I can get it working but a lot of people suggest other methods.

I appreciate the replies though. I'll mess around with it. It's still not working. :p
LOL. I'm almost past caring on this issue.
Figured it out, thanks everyone.
Topic archived. No new replies allowed.