Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Dev-C++ to develop some console apps to study. When my program tries to run

system("PAUSE");

ZA stops it and asks me to allow or deny it. I check the "always" box but it seems that every time I compile it, it generates a new exe file so every time I run it ZA pops up.

Of course the simplest solution is to disable it or deal with it :-P but I'm not eager for any of both. Any suggestions? thanks in advance!

share|improve this question
    
Don't use system("pause"), use getchar(). Or better, don't use any 'press any key...' commands: run your program from a proper CMD.EXE box. –  Renan Sep 4 '12 at 3:26
    
The reason ZA cannot remember your selection is because you are changing the application signature each time you compile it. My suggest generate a expection for the folder the .exe is being run in. –  Ramhound Sep 4 '12 at 13:31
    
@Ramhound That's what I was aiming for with my question! Do you know how to do dat? –  rMaero Sep 4 '12 at 17:04

1 Answer 1

Get rid of system("PAUSE"). If you want to wait for a keypress, use sensible C or C++ code to do that. Don't launch a process.

Also, console applications should never wait for a keypress at the end of their run. Among other things, this makes them unusable in pipelines. If you need the output of a console application after it finishes running, you should run it from a console.

It's not the program's responsibility to ensure it's run in a sane environment. If run from a temporary console, its output will be temporary as it should be. Someone who didn't want that wouldn't run it from a temporary console.

This annoys people who know what they're doing (imagine if you redirect the program's output to a file, for example) and just facilitates people who don't know they're doing to continue to ask for things other than what they want, continuing the cycle of programmers giving them what they didn't ask for.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.