I’m currently trying to make a small application that performs different duties. Right now I have a console app pop up and ask what I want to do, but sometimes I would rather just launch it with something like MyApp.exe -printdocuments or some such thing.
Are there any tutorials out there that can show me a simple example of this?
In C++, your
main()function can haveargcandargvparameters, which contain the arguments passed on the command line. Theargcis the count of arguments (including the executable name itself), andargvis an array of pointers to null-terminated strings of lengthargc.For example, this program prints its arguments:
Any C or C++ tutorial will probably have more information on this.