Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-13-2002, 10:38 PM   #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
newme is offline   Reply With Quote
Old 08-14-2002, 01:04 AM   #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
Justin26k is offline   Reply With Quote
Old 08-14-2002, 02:15 AM   #3
Telcom Tech
 
ktkendall's Avatar
 
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"
ktkendall is offline   Reply With Quote
Old 08-14-2002, 04:59 AM   #4
Member (12 bit)
 
Paul Victorey's Avatar
 
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.
Paul Victorey is offline   Reply With Quote
Old 08-14-2002, 09:14 AM   #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.
newme is offline   Reply With Quote
Old 08-14-2002, 09:43 AM   #6
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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
doctorgonzo is offline   Reply With Quote
Old 08-14-2002, 02:13 PM   #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
newme is offline   Reply With Quote
Old 08-14-2002, 02:28 PM   #8
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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:
#include <iostream.h>
void main () {
    
cout<<"Yo!";
    } 
In Dev-C++, I save it, then click on Execute...Compile. I then open up a DOS prompt, switch to the directory where I saved it, and run it from there. I don't have any problems with the window closing, whereas I do if I run it directly from the Execute...Run command in Dev-C++.
doctorgonzo is offline   Reply With Quote
Old 08-14-2002, 02:31 PM   #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.
newme is offline   Reply With Quote
Old 08-16-2002, 10:54 AM   #10
Member (11 bit)
 
Join Date: Jan 2002
Location: british columbia canada
Posts: 1,361
^^^^^^^^
are you there drgonzo can you help
newme is offline   Reply With Quote
Old 08-16-2002, 10:59 AM   #11
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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.
doctorgonzo is offline   Reply With Quote
Old 08-17-2002, 04:44 AM   #12
Member (12 bit)
 
Paul Victorey's Avatar
 
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.
Paul Victorey is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:22 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2