Hi I am relatively new to programing.
I want to create a C++ program that when you call it in CMD you can pass it variables.
For example in cmd
Myprograme.exe 11 32 232
So that it uses these values in the calculation.
C++
int main(float A, float B, float C){
float sum= A+B+C;
cout << sum;
return 0;
}
My problem is I don’t know what you would call this process to even Google it.
The standard signature of
mainis as follows:argcis the number of comman-line arguments that were given to the program (including argument number 0 which is the program’s name).argvis an array of nul-terminated character strings, each of which contains the appropriate command-line argument.argv[argc]is a null pointer.You can use these to parse the command-line arguments an pass them on to your computation.
For example, if you issue the following on the command line:
argcwill be 4argv[0]will be"myprog.exe"argv[1]will be"a"argv[2]will be"bb"argv[3]will be"c"argv[4]will be the null pointer