I have a c++ program that I call with the following line:
./myProgram
However, I’d like to send some external variables to the program (this will eventually be called from PHP via the exec() method). I’ve searched and read that I should use arguments in the following way:
./myProgram <arguments>
However I’m not exactly sure how to use that. Do I separate the arguments by comma if I have more than one, do I need to put type before? And in the C++ file, how do I get these variables?
Can somebody point me to a tutorial for that? Or any other info, code example?
Thanks!
The command line args to your executable should just be seperated by spaces.
If your arguments are numbers etc… then you convert them to a string and pass that string to the exec command. C/C++ only accept string arguments in their main functions.