Why does the program not show on screen?

closed account (4z0M4iN6)
It's easy to understand, if you know.

There are two ways for avoiding this behaviour:

- you could start the program from a console window (dos prompt)
- you could insert #include <conio.h> at the begin of your source file and _getch(); at end of main
Last edited on
You could also add cin.get(); at the end of your code.

This requires #include <iostream> - but you have already included that.

This way (and dadabe's method) lets the program wait for a) user to hit enter (using cin.get) or b) user to hot any key (using getch).
Last edited on
This has already been discussed ad nauseum...
http://cplusplus.com/forum/beginner/1988/
closed account (4z0M4iN6)
Maybe we should rename "Console Closing Down" to "Why does the program not show on screen"?

Because I thought you have some problem with your sever here, and it would mean something like "Server Shut Down".

A sincere thanks to all who answered. This has solved the problem with dadabe 's solution.
My apologies to cnoeval. I guessed this had been asked many times, I am not up with the internet that well, as stated in the beginning line, I am a raw beginner. So raw in fact that it hurts. :-)

Thanks all
Jacko
To my shame, I didn't thank AbR for his valuable input. This also worked a treat. Pity the CIN.GET(); command didn't show in the Dev-Cpp tutorials. Still, it was free and for the most part written very clearly.

Again thanks all....
Jacko
No need to apologize for being a newbie and it's a nice touch to post some thanks when you've been helped. 8^)

BTW, most IDEs (i.e. Visual Studio Express Edition which is FREE) provide various ways to hold the console window open for you without have to add extraneous code. Dev-C is very old and no longer supported so if you have the option to upgrade to a better IDE/compiler you will have an easier time coding. Once you learn to use the new IDE of course ;-).

Link to this forums IDE threads: http://www.google.com/search?q=IDE&as_sitesearch=cplusplus.com

@ dadabe: Good point but most people DO see the console window for a second before it disappears and of course the post was named by the original poster so it's not really fair to change it.
Hello cnoeval,
I got interested in C++ quite a few months ago. I saw a book advertised: "C++ Programming for the absolute beginner"
I ordered it and when it came, the first disappointment came with it. It was written specifically for "Code Warrior V5.0". Well try as I might, noone had heard of this version. The nearest I could get was V5.1. This of course has slightly different syntax ans as such was pretty much useless to me.
That's why I tried the Dev-CPP. Seems like I was a loser both ways :-)
At my age, I don't want to part with any more money, but I will struggle on with what I have.
Thanks again for the input.
Jacko
@Jacko99

'Code Warrior' is C programming for Windows OS, Pocket PC.
Hello whitenite1,
like I said... I am a total beginner and ripe for the picking. Didn't know what was what, to start with. That's why I don't want to part company with any more cash, at least not until I get started with C++. Once up and running with something that I am able to refer back to, then I might purchase something a little more upmarket, so to speak. Thank you for your input.
Jacko99
Well, as cnoeval mentioned, Visual Studio Express Edition is free, 2008 or 2010 versions. As for books, try going to your public library, and search for C++ books to borrow. Take a couple out for a couple of weeks, decide which one fits your learning style, and buy it at the store, or when it's time to return it, ask for an extension. If you're lucky, you can go through most of the book in that time, and at no cost. After returning, take out another. Good luck in your programming..
Thanks for that whitenite1, never thought about it that way. Didn't know that visual studio was a free program either. I will go online when I finish this email and get into it.
Hope the syntax isn't too different to the C++ I have been fiddling with, the answer will come as soon as I get started on it. If all turns out well, I will buy a book for future reference rather than travel to the library every time I get the urge to try something different.
Great idea and thanks again,
Jacko99
@Jacko99
I didn't mean for you to have to travel to the library every time you got the urge, but to try out a book or two first, to see if you feel it is helpful in your learning style, BEFORE making a purchase s you don't end up with a book that may be way to easy for you, or, on the other hand, way over your head at the moment. It would like taking a car out for a test drive before making a final decision on a purchase.
And in case you haven't found 'Visual Studio Express' yet, here is the URL of the site. http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express

Good luck on your programming, and you're very welcome..
Topic archived. No new replies allowed.