C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 18th, 2004, 02:25 AM
doughnut doughnut is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 12 doughnut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #2  
Old June 18th, 2004, 02:41 AM
B-Con's Avatar
B-Con B-Con is offline
Crypto-Con
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Apr 2004
Location: Frisco, Texas
Posts: 6,704 B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level) 
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.
)

Reply With Quote
  #3  
Old June 18th, 2004, 02:41 AM
jacktasia jacktasia is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: Lawrence, Kansas [KU]
Posts: 1,559 jacktasia User rank is Corporal (100 - 500 Reputation Level)jacktasia User rank is Corporal (100 - 500 Reputation Level)jacktasia User rank is Corporal (100 - 500 Reputation Level)jacktasia User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 14 h 10 m 18 sec
Reputation Power: 14
Send a message via AIM to jacktasia
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.

Reply With Quote
  #4  
Old June 18th, 2004, 04:15 AM
macar macar is offline
Maciej Ignacy Arciuch
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Warsaw, Poland
Posts: 56 macar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 25 sec
Reputation Power: 10
Send a message via ICQ to macar
Place
Code:
system("PAUSE");


at the end of your program.

Hope this helps,
Matthew

Reply With Quote
  #5  
Old June 18th, 2004, 07:43 AM
3dfxMM 3dfxMM is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 272 3dfxMM User rank is Sergeant (500 - 2000 Reputation Level)3dfxMM User rank is Sergeant (500 - 2000 Reputation Level)3dfxMM User rank is Sergeant (500 - 2000 Reputation Level)3dfxMM User rank is Sergeant (500 - 2000 Reputation Level)3dfxMM User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 17 h 57 m 24 sec
Reputation Power: 17
Run it from a command shell.
Comments on this post
kicken agrees: As it was ment to be run.

Reply With Quote
  #6  
Old June 18th, 2004, 08:51 AM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Renaissance Redneck
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 8,509 DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level) 
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 Pointers Politically Incorrect.

Reply With Quote
  #7  
Old June 18th, 2004, 09:36 AM
Watever Watever is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Montreal, Canada
Posts: 486 Watever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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 !
__________________

Reply With Quote
  #8  
Old June 19th, 2004, 05:26 AM
jubitzu jubitzu is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: Colorful Colorado
Posts: 743 jubitzu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #9  
Old October 24th, 2004, 05:08 AM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Renaissance Redneck
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 8,509 DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level) 
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.

Reply With Quote
  #10  
Old November 21st, 2004, 11:03 PM
Dictionary's Avatar
Dictionary Dictionary is offline
Registered User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Nov 2004
Location: Ottawa, ON
Posts: 2,059 Dictionary User rank is Sergeant Major (2000 - 5000 Reputation Level)Dictionary User rank is Sergeant Major (2000 - 5000 Reputation Level)Dictionary User rank is Sergeant Major (2000 - 5000 Reputation Level)Dictionary User rank is Sergeant Major (2000 - 5000 Reputation Level)Dictionary User rank is Sergeant Major (2000 - 5000 Reputation Level)Dictionary User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 10 h 50 m 52 sec
Reputation Power: 48
cin.get();
or system("PAUSE");
or getchar();
or (maybe I'm just guessing) getint();, getfloat();
and many others
C++ right?

Last edited by pmam21 : October 19th, 2005 at 11:43 PM.

Reply With Quote
  #11  
Old November 22nd, 2004, 06:48 AM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Renaissance Redneck
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 8,509 DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level)DaWei_M User rank is General 34th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Weeks 17 h 53 m 58 sec
Warnings Level: 20
Number of bans: 3
Reputation Power: 3268
He asked back in June, pmam. One would hope he's not still grappling around inside his tower looking for the disappeared window.

Reply With Quote
  #12  
Old February 5th, 2006, 12:06 AM
lbindu lbindu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 1 lbindu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #13  
Old February 5th, 2006, 12:38 AM
Izkata Izkata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 51 Izkata User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.
Comments on this post
Anticastleism disagrees: Why worry about it?

Reply With Quote
  #14  
Old October 31st, 2012, 09:42 AM
pKu101 pKu101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 pKu101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 31 sec
Reputation Power: 0
Smile

Quote:
Originally Posted by macar
Place
Code:
system("PAUSE");


at the end of your program.

Hope this helps,
Matthew


thanks...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > program ends in miliseconds?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap