why does it compile but not run?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 1
Reputation: philzz is an unknown quantity at this point 
Solved Threads: 0
philzz philzz is offline Offline
Newbie Poster

why does it compile but not run?

 
0
  #1
Jan 3rd, 2009
Using Dev-cpp, a small program compiles but the resultant .exe file
does not run. From the DOS command, it runs. When I try from the
windows run command , it flashes but immediately goes away.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,836
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: why does it compile but not run?

 
0
  #2
Jan 3rd, 2009
Originally Posted by philzz View Post
Using Dev-cpp, a small program compiles but the resultant .exe file
does not run. From the DOS command, it runs. When I try from the
windows run command , it flashes but immediately goes away.
http://www.dreamincode.net/forums/showtopic30581.htm
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 20
Reputation: bamabambhole01 is an unknown quantity at this point 
Solved Threads: 0
bamabambhole01 bamabambhole01 is offline Offline
Newbie Poster

Re: why does it compile but not run?

 
0
  #3
Jan 3rd, 2009
Originally Posted by philzz View Post
Using Dev-cpp, a small program compiles but the resultant .exe file
does not run. From the DOS command, it runs. When I try from the
windows run command , it flashes but immediately goes away.
try ./filename
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,117
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 282
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: why does it compile but not run?

 
0
  #4
Jan 4th, 2009
Originally Posted by bamabambhole01 View Post
try ./filename
What does this do?
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 117
Reputation: u8sand is on a distinguished road 
Solved Threads: 15
u8sand's Avatar
u8sand u8sand is offline Offline
Junior Poster

Re: why does it compile but not run?

 
0
  #5
Jan 4th, 2009
  1. cin.ignore(); // this ignores one enter key

or

  1. system("pause");
  2. // should use cin.ignore but you can use this
  3. // it displays: "Press any key to continue..."
  4. // and when you press any key, it continues...

or as veron was saying

  1. // Before using this make sure you have included: #include <windows.h>
  2. Sleep(1000);
  3. // the amount you put is in miliseconds, 1000 = 1 second
  4. // this will wait the amount of time you put into before moving on.
put that in, and you will press enter before the window closes..

atm it is running correctly but it doesent know you want it to wait till you want to end it, so you have to add that.
Last edited by u8sand; Jan 4th, 2009 at 9:41 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 70
Reputation: orwell84 is an unknown quantity at this point 
Solved Threads: 3
orwell84's Avatar
orwell84 orwell84 is offline Offline
Junior Poster in Training

Re: why does it compile but not run?

 
0
  #6
Jan 4th, 2009
Small programs usually run in command prompt...if you want it to have its own window, that's a different matter.
Last edited by orwell84; Jan 4th, 2009 at 11:59 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 390
Reputation: skatamatic will become famous soon enough skatamatic will become famous soon enough 
Solved Threads: 39
skatamatic skatamatic is offline Offline
Posting Whiz

Re: why does it compile but not run?

 
1
  #7
Jan 6th, 2009
  1. cin.ignore(cin.rd_buf()->in_avail());
  2. cin.get();

Slap that on the end of the code. This will do the following:
ignore all the available input from the cin (console) input buffer, then grabs a null terminated character (basically waits until you hit enter).
Last edited by skatamatic; Jan 6th, 2009 at 6:23 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC