C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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, 03: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, 03: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: UC Davis
Posts: 6,664 B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level)B-Con User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 21 h 53 m 29 sec
Reputation Power: 879
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 recieved so far -- Latest donor: Mark Foxvog
)

Reply With Quote
  #3  
Old June 18th, 2004, 03: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 4 m 35 sec
Reputation Power: 9
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.
__________________
Jack
---------
use code tags

become vegetarian
python? yes, sir!
unarm.org
get firefox


If I helped you then please click the "" in the upper right-hand corner of my post.

Reply With Quote
  #4  
Old June 18th, 2004, 05: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: 5
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, 08:43 AM
3dfxMM 3dfxMM is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 267 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: 4 Days 2 h 4 m 28 sec
Reputation Power: 13
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, 09:51 AM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Permanently Banned
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 7,351 DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 19 h 39 m 7 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
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.

Reply With Quote
  #7  
Old June 18th, 2004, 10: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: 6
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, 06:26 AM
jubitzu jubitzu is offline
Permanently Banned
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, 06:08 AM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Permanently Banned
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 7,351 DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 19 h 39 m 7 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
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 22nd, 2004, 12:03 AM
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: 44
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 20th, 2005 at 12:43 AM.

Reply With Quote
  #11  
Old November 22nd, 2004, 07:48 AM
DaWei_M's Avatar
DaWei_M DaWei_M is offline
Permanently Banned
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
Posts: 7,351 DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level)DaWei_M User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 19 h 39 m 7 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
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, 01: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, 01: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: 5
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
Reply

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


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 |