How to run a c++ code say (test.cpp) from command line as:
./solve l m
where l and m = input variable for test.cpp
solve is the object / Executable file for test.cpp.
I know that i can create a object file with
g++ test.cpp -o solve
but how do i make
./solve l m
work ??
Main() takes two inputs. The first (argc) is the number of inputs (in your case 2, l and m), and it puts the two into a char* array (argv[]). So in main you’d do:
Read parsing command line args here:http://www.site.uottawa.ca/~lucia/courses/2131-05/labs/Lab3/CommandLineArguments.html