I have a program that reads hard-coded file-path and I want to make it read file-path from command line instead. For that purpose I changed the code like this:
#
It's already an array of C-style strings:
#include
#include
#include
int main(int argc, char *argv[]) // Don't forget first integral argument 'argc'
{
std::string current_exec_name = argv[0]; // Name of the current exec program
std::vector all_args;
if (argc > 1) {
all_args.assign(argv + 1, argv + argc);
}
}
Argument argc
is count of arguments plus the current exec file.