i don't want the dos wondow be closed

K

#kiss#

hey guy !!

i m a beginer on C prog...i m using DEV-C IDE but when i m running a .EXE
the dos window open , run the .EXE and closed quickly, how could i do if i
don't want the dos window closed....what kind of code could i write at the
end ??
 
P

pete

#kiss# said:
hey guy !!

i m a beginer on C prog...i m using DEV-C IDE
but when i m running a .EXE
the dos window open , run the .EXE and closed quickly,
how could i do if i
don't want the dos window closed
....what kind of code could i write at the end ??

Find out where the compiler puts a.exe,
and then open a window there,
and then run a.exe from that window, instead of from the IDE.
 
I

Irrwahn Grausewitz

[Please don't top-post]
Did you try using getch() as the last statement of your main.

Since getch() is not a standard C function, use getchar() instead.
 
D

Dan Pop

In said:
i m a beginer on C prog...i m using DEV-C IDE but when i m running a .EXE
the dos window open , run the .EXE and closed quickly, how could i do if i
don't want the dos window closed....what kind of code could i write at the
end ??

Obviously, some code expecting you to press the Enter key before
continuing. Even as a beginner you should be able to figure it out.

Or, don't bother at all and keep a console window permanently open.
Rebuild the program from the IDE, but execute it from your console.

Dan
 
P

Peter Nilsson

Irrwahn Grausewitz said:
[Please don't top-post]
Did you try using getch() as the last statement of your main.

Since getch() is not a standard C function, use getchar() instead.

The OP will probably need two of them if they are reading input with scanf.

If the code only has one getchar call, it will typically swallow the newline left in the
stream and the program will exit immediately (closing the window) as before.
 
I

Irrwahn Grausewitz

Peter Nilsson said:
The OP will probably need two of them if they are reading input with scanf.

If the code only has one getchar call, it will typically swallow the newline left in the
stream and the program will exit immediately (closing the window) as before.

Correct, but actually I use this as a test from time to time:
if the program didn't stop on the final getchar(), I know my
code failed to correctly consume all given input.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top