Console Application
-
Hi,
i have written a small console application which I can use it in the command prompt.
If i double click the exe file the command prompt opens and closes immediately.Is there a way that the command prompt do not close?
- Is there a way that the command prompt do not close?
Yes if your app do not close. :)
Then command prompt stays open. -
- Is there a way that the command prompt do not close?
Yes if your app do not close. :)
Then command prompt stays open.The structure of the code is:
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QStringList arguments = a.arguments(); // check arguments // do stuff and return }
I don't enter the main event loop. After checking all arguments and doing the stuff the application returns.
-
Add a.exec() at the end of your code in main. It shud stop
-
[I'm assuming you are on Windows] Without polluting your code, the correct way to use that .exe is:
- open the command prompt (cmd.exe)
- [optional] navigate with
cd
to the directory from which you want to start the program - type the absolute path to your exe (use
"
around it to prevent failure due to spaces or other reserved chars in your path to interfere)
-
[I'm assuming you are on Windows] Without polluting your code, the correct way to use that .exe is:
- open the command prompt (cmd.exe)
- [optional] navigate with
cd
to the directory from which you want to start the program - type the absolute path to your exe (use
"
around it to prevent failure due to spaces or other reserved chars in your path to interfere)
-
You're right, thats exactly the way i use the application. But if you could skip the three steps by double clicking the .exe file, it would be very nice.