I have a program in C++ which I run for many values of a parameter. What I want to do is the following:
Let’s say I have two parameters as:
int main(){
double a;
double b;
//some more lines of codes
}
Now after after I compile I want to run it as
./output.out 2.2 5.4
So that a takes the value 2.2 and b takes the value 5.4.
Of course one way is to use cin>> but I cannot do that because I run the program on a cluster.
You need to use command line arguments in your
main:This code parses parameters using
atof; you could usestringstreaminstead.