Question: I am trying to hardcode arguments that are passed to the [OpenCV Command Line Parser](http://%20https://docs.opencv.org/3.0-beta/modules/core/doc/command_line_parser.html). In the [object\_detection file](https://github.com/opencv/opencv/blob/master/samples/dnn/object_detection.cpp), I have added the code as such, so that I do not have to enter the file name via command-line: 

**Line 40-48:**

```
void drawPred(int classId, float conf, int left, int top, int right, int bottom, Mat& frame);

void callback(int pos, void* userdata);

int main(int argc, char** argv)
{
    // This line added below:
    argv[1]="-input /home/Videos/test.mp4";

    CommandLineParser parser(argc, argv, keys);
    parser.about("Use this script to run object detection deep learning networks using OpenCV.");
    if (argc == 1 || parser.has("help"))

```

OpenCV skips using this file, and switches to camera instead. How can I hardcode the arguments, before they are passed to the Command Line Parser ?

Answer: 
and what is `argc`? if it's 0, it'll be ignored, and pointer in argv will be NULL, so you get UB. Also, modifying system storage supplied to main is a bad idea, it's likely an UB because you don't have proper storage available to store string. 

The only proper way about this is create intermediate variables. Note that array should be NULL-terminated.
The problem is that `argc,argv` are an old-style C mechanism. You can't simply insert a value in the C array `char**`. Instead, you must create a new array with one extra element. (Your existing code *overwrites* `argv[1]`)

Now there's more unusual stuff. `argv` is an array with `argc+1` elements, the last one of which is `nullptr`. Since you're inserting a new element, you must create an `char*[argc+2]*`, copy all `argc` elements, append the pointer to your string, and then terminate the new array with `nullptr`.

You can now pass the new array and `argc+1` to `CommandLineParser`.