To start a different software than your own program (with or without arguments) you can use system() from <cstdlib>
header.
#include <cstdlib>
int main(int argc, char* argv[]) {
system("start putty -ssh user@server -pw password");
return 0;
}
If you want to evaluate the arguments to your own program, you can use argv[]
. argv[0]
holds the name/path of your program, and argv[1] ... argv[argc-1]
the actual arguments i.e.
#include <cstring>
#include <iostream>
int main(int argc, char* argv[]) {
if ((argc > 1) && (!strcmp(argv[1], "-help"))) {
std::cout << "Showing help" << std::endl;
}
return 0;
}
2
solved C++ Open software with argument