Discuss program ends in miliseconds? in the C Programming forum on Dev Shed. program ends in miliseconds? C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
program ends in miliseconds?
i wroe the hello world program but after compiling it using bloodshed, i go to the directory where i saved it click on the file and a dos window comes up saying hello world for litrully miliseconds i had to keep clicking it to see that it said hello world why does it shut its self down straight away?
Posts: 6,704
Time spent in forums: 1 Month 6 Days 6 h 45 m 21 sec
Reputation Power: 1235
The window will automatically close when the code finishes running, you need to hold it in some way...
Place getchar(); at the end of your code, this will wait until you press the 'enter' key before continuing....
__________________
- "Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
- Why know the ordinary when you can understand the extraordinary?
- Sponsor my caffeine addiction! (36.70 USD received so far -- Latest donor: Mark Foxvog.)
Posts: 1,559
Time spent in forums: 2 Days 14 h 10 m 18 sec
Reputation Power: 14
because the function is over. usually if you run it through debuggers you can have it do something like "press any key to continue" so you can actually see your output. but if you can't do that then just ask for an input from the user at the end of the program, that way it will pause and you can read it for as long as you want.
Location: Central New York. Texan via Arizona, out of his element!
Posts: 8,509
Time spent in forums: 4 Weeks 17 h 53 m 58 sec
Warnings Level: 20
Number of bans: 3
Reputation Power: 3268
One person's "pause" is another person's "PAUSE." For a learning exercise such as yours, pick the solution from the above that works in your environment and suits your goal (least exasperation, easiest, quickest, most productive, whatever), bearing in mind that instant gratification may breed bad habits.
__________________
Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it. DaWei on PointersPolitically Incorrect.
Posts: 486
Time spent in forums: 3 h 52 m 20 sec
Reputation Power: 10
Quote:
Originally Posted by 3dfxMM
Run it from a command shell.
exactly
if you are in windows
go on Run Commands, type "cmd" + enter, it should prompt a console, then just go run your application, you will read it without problem !
Posts: 743
Time spent in forums: 21 h 16 m 10 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
i havent done this in a while, and i dont have a windows machine on which to test this, but i do believe that you can edit a .pif file to make the console window stay open after the program stops executing. of course this could all be a figment of my imagination.
__________________
Ignore me because I have a terrible reputation.
Location: Central New York. Texan via Arizona, out of his element!
Posts: 8,509
Time spent in forums: 4 Weeks 17 h 53 m 58 sec
Warnings Level: 20
Number of bans: 3
Reputation Power: 3268
Start by reading the FAQ, first post at the top of the forum. Follow the thread that relates to the console window slamming shut on you. There are numerous explanations, examples, and work-arounds. It's an uncommonly common question.
Posts: 1
Time spent in forums: 22 m 12 sec
Reputation Power: 0
anything
Include the file #inlcude <conio.h> and call the function getch( ); at the end of the programm. By calling this function the output will be closed only when you hit any key.
Posts: 51
Time spent in forums: 20 h 44 m 41 sec
Reputation Power: 10
Ibindu, please don't reply to long-dead threads. The last post in this thread was over a year ago, which itself was several months after the question was asked.
There is a line above each post that says when it was made.