|
1. Dev C++
|
|
Sun Apr 23, 2006 [7:11 AM]
|
Half
halfofnutin@verizon.net
member since: Jan 29, 2006
|
Reply
|
|
In the Dev-C+ compiler, when I compile this Code: #include
void main() { printf("Goodbye, Cruel World!\n"); }
the window tht pops up after compile and run, stays for less than a second, not even enough time to read it, then it poofs away.
unless I add getch(); at the end
|
|
|
|
|
2. RE: Dev C++
|
|
Sun Apr 23, 2006 [10:13 AM]
|
lockheed
Email not supplied
member since: Aug 31, 2003
|
In Reply To
Reply
|
|
Sounds like it's doing what it's supposed to do.
If you don't like getch, try running your program from the command prompt.
|
|
|
Clinton K.
I could have stayed in the past, could have even been king, but in my own way, I am king. Hail to the King baby.
|
|
4. RE: Dev C++
|
|
Sun Apr 23, 2006 [8:58 PM]
|
Tyche
Email not supplied
member since: Apr 4, 2000
|
In Reply To
Reply
|
CLiCk on teh StaRt button. click run... In the little window type: cmd.exe hit enter A magic black window appears that says something like...
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Droppings and Leavings\myname>
type help look at all the commands switch to the directory your program was compiled to. > cd \the\directory\my\program\was\compiled\to run the program > myprogram.exe more fun after done.
|
|
|
|
|
5. RE: Dev C++
|
|
Mon Apr 24, 2006 [12:03 PM]
|
Mentalia
Email not supplied
member since: Oct 30, 2000
|
In Reply To
Reply
|
|
I'm guessing this is MS Visual Studio C++?
In which case, F5 runs a program in the debugger and closes it after program exit.
Control-F5 does not run the program in the debugger and leaves the window after program exit.
Might vary betwee versions, but this works for me in versions 4, 6, and 7...
|
|
|
|
|
7. RE: Dev C++
|
|
Fri Apr 28, 2006 [10:15 PM]
|
Gilthil
Email not supplied
member since: Nov 27, 2000
|
In Reply To
Reply
|
|
Its doing that because there is nothing in your code that would keep the window open, except when you include the getch(). So, its doing what its supposed to do.
BTW, running it from the command prompt without the getch() would do the same thing, it would just close right away.
I don't have any experience with DevC++ so I don't know if there's an option to keep the program open. Just keep using getch() until you put code into it that would keep it running, i.e. a while or for loop.
|
|
|
|
|
8. RE: Dev C++
|
|
Sat Apr 29, 2006 [1:40 AM]
|
kiasyn
Email not supplied
member since: Apr 29, 2006
|
In Reply To
Reply
|
|
Adding in system("pause"); also works
|
|
|
|
|
9. RE: Dev C++
|
|
Sat Apr 29, 2006 [7:30 PM]
|
wolfpaw
Email not supplied
member since: Sep 24, 1999
|
In Reply To
Reply
|
|
At the risk of this sounding like a flame.. which it rather is.. why the hell would you use a system call to pause?!?? that makes no good sense whatsoever. Use of a system call should be avoided at all costs.. they are dangerous, and have fairly high overhead.
-D.
|
|
|
|
|
10. RE: Dev C++
|
|
Sat Apr 29, 2006 [10:11 PM]
|
Gilthil
Email not supplied
member since: Nov 27, 2000
|
In Reply To
Reply
|
|
Seeing how the program the original poster is trying to run is simply a "Hello, World!" program, security and overhead isn't something to be overly concerned about. In a MUD you'd be right, but in this case, does it really matter what someone chooses to use to keep the output window from closing?
|
|
|
|
|
11. RE: Dev C++
|
|
Sat Apr 29, 2006 [11:40 PM]
|
Tyche
Email not supplied
member since: Apr 4, 2000
|
In Reply To
Reply
|
|
why the hell would you use a system call to pause?!??
He could use... while (true);
I recommend... a: goto a;
system('pause'); ... is unsafe and will not generate nearly as much heat from the CPU as the other two.
|
|
|
|
|
12. RE: Dev C++
|
|
Sat Jun 10, 2006 [11:54 PM]
|
Razazarak
Email not supplied
member since: Jun 10, 2006
|
In Reply To
Reply
|
|
the man is trying to print "Hello, world" now why the hell NOT use a system("pause"). All hes doing is "Hello, world" for god sakes. Yes true in a mud you want to avoid it...however theres not much to need to avoid in something like this. However I would seriously would also suggest not using a goto...just something my C++ instructor taught me. if you wanted to get a little fancy you could make it to where you talk to the computer...using a cin. So try this code with a cin string...mabye you can tack some stuff on it by using if statements:
#include
using namespace std;
int main() { string response;
cout << "Hello, World" << endl; cin >> response; return 0; }
|
|
|
retaliation.wolfpaw.net
join us!!
|
|
13. RE: Dev C++
|
|
Thu Jun 15, 2006 [3:41 AM]
|
Viat
Email not supplied
member since: Jun 12, 2006
|
In Reply To
Reply
|
|
Your cin is pretty much the same as the getch(); though - both just wait for user input. the a: goto a; and while (true) are both going to chow massive amounts of processing time - maybe while (true) { sleep(500) } or whatever the equivalent is.
Abandoning the over-analyzing for a second though - the problem is clearly programmer karma, for writing the depressive
(Comment added by Viat on Thu Jun 15 4:42:15 2006)
"Goodbye, cruel world!" instead of the spiritually approved, zen-like calm inducing "Hello World!". I think that should be fixed, and the program should be run inna console.
In other news - hi everyone, first post. Anyone know why my post was being cut in half?
|
|
|
|
|
14. RE: Dev C++
|
|
Thu Jun 15, 2006 [1:51 PM]
|
Drey
Email not supplied
member since: Mar 19, 2000
|
In Reply To
Reply
|
|
In other news - hi everyone, first post. Anyone know why my post was being cut in half?
First-poster karma.
|
|
|
|
|