943,816 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 757
  • C++ RSS
Jan 3rd, 2009
0

why does it compile but not run?

Expand 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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
philzz is offline Offline
1 posts
since Jan 2009
Jan 3rd, 2009
0

Re: why does it compile but not run?

Click to Expand / Collapse  Quote originally posted by philzz ...
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
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,374 posts
since Jan 2008
Jan 3rd, 2009
0

Re: why does it compile but not run?

Click to Expand / Collapse  Quote originally posted by philzz ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bamabambhole01 is offline Offline
20 posts
since Apr 2008
Jan 4th, 2009
0

Re: why does it compile but not run?

try ./filename
What does this do?
Moderator
Reputation Points: 3278
Solved Threads: 892
Posting Sage
WaltP is offline Offline
7,718 posts
since May 2006
Jan 4th, 2009
0

Re: why does it compile but not run?

C++ Syntax (Toggle Plain Text)
  1. cin.ignore(); // this ignores one enter key

or

C++ Syntax (Toggle Plain Text)
  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

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 78
Solved Threads: 15
Junior Poster
u8sand is offline Offline
131 posts
since Dec 2008
Jan 4th, 2009
0

Re: why does it compile but not run?

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.
Reputation Points: 17
Solved Threads: 5
Junior Poster
orwell84 is offline Offline
100 posts
since Nov 2008
Jan 6th, 2009
1

Re: why does it compile but not run?

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 352
Solved Threads: 109
Master Poster
skatamatic is offline Offline
775 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: funtion that returns array?
Next Thread in C++ Forum Timeline: Polymorphism : doesn't work: massive of base class for derivated ones





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC