Q:

How do you take user inputer upon executing your program through terminal?

Part of an assignment requires me to define the input file names upon calling the program to be run through terminal, thus far I have my program implemented to take user input for the filename after its opened but how do we do it before including a flag of 0 or 1 input?
the idea
terminal: ./test.exe -filename- -flag-

A:

You can do it by declaring your main like so
int main(int argc, char* argv[]) 

argvis an array of c-style strings and argc is how many c-style strings in argv.
Together they give you the program's command-line arguments
You can try this code as an example
#include <iostream>

int main(int argc, char* argv[]) {
    std::cout << "Have " << argc << " arguments:" << std::endl;
    for (int i = 0; i < argc; ++i) {
        std::cout << argv[i] << std::endl;
    }
}

Then when running your program you call it like so Example.exe "./test.txt" 0 which will output
Have 3 arguments:
Example.exe
./test.txt
0

