Question:
Could someone help with this command prompt and C language problem?
2012-02-04 13:55:43 UTC
I am writing programs in C. I compiled it into an exe file but when i go to the directory and double-click on it it just flashes a command prompt window and exits straightaway. i then have to go to command prompt, navigate to the folder, and open the .exe from there. is there any way i can just click on the .exe file and it will open normally? all that typing in command prompt is ok, but it gets tedious!
Four answers:
jplatt39
2012-02-04 14:02:14 UTC
If you don't run it from the command prompt then add this line at the end of it (just before return 0;)



system("pause");
Jonathan
2012-02-04 15:28:10 UTC
If you are using Visual Studio, you can start the program with ctrl-F5 (without debugging) and a console application will then automatically pause at exit. You can add code to do something similar, either with system("pause") or with getch() or some other method like that. But I usually just use ctrl-F5 and get by with that. If you aren't in the IDE environment, you probably do need to set up a cmd.exe link to the directory and just run it as a command line, or else add in that system("pause") line to the end of the code. There used to be a way to uncheck "close on exit" on the properties page, but that seems gone now on the standard dialog box. It's possible that there is a "power tool" available that accesses more features, though. So that might be another possible approach to look for on google.



Finally, you can create a cmd.exe shortcut. If you place a "/k" followed by the program name in the Target box for the properties page, that will keep the CMD.EXE box displayed after the program exits. You will probably need to specify the "Start in" directory, too, in your shortcut. But if you do those things, it will run the program for you and when the program exits, you will get back the command line prompt and the box won't automatically destroy itself. (For those cases where you actually want it to self-destruct, use the "/c" instead of "/k".
prahasky
2016-12-09 07:11:14 UTC
i'm sorry yet you have provided a mummble-bumble. Assembler could be used for: a million. Embedded structures that have very very limiter source (ex. 1kB memory, 1MHz CPU, elementary instructions, in basic terms numerous registers). 2. Optmization in latest purposes. you're able to on no account create purposes in organic assembler. i admire assembler yet working with it each and daily is a suicide. you have provided some thing that tells no longer something. what's the "upload" used for? the place is the enter examine from? what's estimated output? i'm sorry yet your question is UNREADABLE to that end i visit mark it so.
2012-02-04 14:05:06 UTC
well what di you expect. the program finished and exited.



Read/wait for keyboard input to wait for exst program.



Console::ReadLine(); if VS.

or

while (1)

{

if ('n' == getchar())

break;

}


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...