|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (11 bit)
Join Date: Jan 2002
Location: british columbia canada
Posts: 1,361
|
compiler help
hello
im trying to do simple progs with dev c++ compiler it compiles and says no mistakes, successful.but when i execute run, the dos window flashes quickly and doesnt open, just a quick flash anddissappears what am i doing wrong thanks |
|
|
|
|
|
#2 |
|
Banned
Join Date: Jul 2002
Posts: 257
|
Nothing that is just how DOS is run your program from the command prompt and it will be fine hope this helps
|
|
|
|
|
|
#3 |
|
Telcom Tech
Join Date: Feb 2002
Location: Western, Pa.
Posts: 5,409
|
What OS are you using??
I remember when I took C++, it seems to me that under win98, my dos window would stay there for me no matter how small the program, and I would get to see what it does then exit the dos window manually. Even the "HELLO WORLD" program would stay for me. I wonder if your using XP, cause I notice that if I go thru the run box and do something like ping an IP address, it does just what you are describing with that dos window flashes before me so fast I can't even see what it did. Don't forget too, that just because you have no compiler errors, you can have runtime errors, and just like many of the cases of trouble I go out on every day, the box is doing exactly what it was told to do and there is really no fault in hardware or software, it just that the human involved told it to do the wrong thing. I doubt that is the case in your simple programs though, but if your under win2000, or xp then that may be the way it works if it's just a small program that requires no user input! I believe Justin's suggestion will work for you!
__________________
If it ain't broke, "TWEAK IT" |
|
|
|
|
|
#4 |
|
Member (12 bit)
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
|
Open the DOS prompt manually, and execute the program. It won't close the window if you opened it yourself.
Or, alternately, make the program not terminate until a key is hit. Or make a batch file that executes your program, then the pause command. |
|
|
|
|
|
#5 |
|
Member (11 bit)
Join Date: Jan 2002
Location: british columbia canada
Posts: 1,361
|
thanks for the replies im using 98, se paul victory this is simple hello world thats as advanced as i get.i dont know how to use batch files and how do i use the commmand line.
|
|
|
|
|
|
#6 |
|
Professional gadfly
|
The command line is the DOS prompt. Just open up a DOS prompt, switch to the directory where your compiled EXE is, and run it from there.
A batch file has a BAT extension and simply contains a bunch of DOS commands and programs to run, one after another. The most familiar batch file is the Autoexec.bat, which is the batch file that runs when you first start your computer. To make a batch file, simply put commands in a text file and save it with a BAT extension. A batch file to run your program could simply contain these three lines: ECHO OFF HELLO.EXE (or whatever you named your program) PAUSE |
|
|
|
|
|
#7 |
|
Member (11 bit)
Join Date: Jan 2002
Location: british columbia canada
Posts: 1,361
|
i was reading the faq in devc++ it said to use
system("pause");it appearred for a second longer but still didnt stay on. the compiler faq said to use this command to keep the dos window open.there must be a way to compile and run from the compiler and the dos window stay on until prompted . thanks |
|
|
|
|
|
#8 |
|
Professional gadfly
|
After you compile a program, open up a DOS prompt, switch to the directory the binary is stored in, and then run the program.
For example, here's my Hello program (excuse the horrible programming ):PHP Code:
|
|
|
|
|
|
#9 |
|
Member (11 bit)
Join Date: Jan 2002
Location: british columbia canada
Posts: 1,361
|
thankyou dr.gonzo i appreciate your time and patience
so if i save it to my documents when the dos prompt opens do i do this c:\windows>my documents\name of the file i saved Last edited by newme; 08-14-2002 at 02:46 PM. |
|
|
|
|
|
#10 |
|
Member (11 bit)
Join Date: Jan 2002
Location: british columbia canada
Posts: 1,361
|
^^^^^^^^
are you there drgonzo can you help |
|
|
|
|
|
#11 |
|
Professional gadfly
|
Yes, that should work. Usually, though, I try to create a separate directory entirely for code, off the root (like C:\CPP or something like that). Not only does it keep your code separate from your word processing and other files, it is easier to run them. Just type CD \CPP at the prompt, and you will be in your code folder.
|
|
|
|
|
|
#12 |
|
Member (12 bit)
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
|
Also, if system("pause"); doesn't work, you can put the following:
while(!kbhit()); in there. You would have to add an #include <conio.h> if you didn't have that already. That's not truly good style (it's platform specific, and not ANSI standard) but it should work. Although... DevC++ might not like that, it may demand you use ANSI standard code. It's a port of a UNIX compiler, I believe, it may not let you use the nonstandard commands. You can try it out and see if it works or not. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|